diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2010-08-16 02:56:52 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2010-08-16 02:56:52 +0200 |
commit | 43136cc7bfb9a44db2800fdfb360e08e36e6f7c2 (patch) | |
tree | 1789244540069b47a6a4d3d44e8f2b11c70d88ee /commands.c | |
parent | 9510dcdf4d03a69da1398bc408fb937485c3c76f (diff) |
Fixed error handling in httpd and commands.
Diffstat (limited to 'commands.c')
-rw-r--r-- | commands.c | 20 |
1 files changed, 16 insertions, 4 deletions
@@ -44,7 +44,8 @@ static void commands_get_raw(GSocketConnection *connection, const gchar *cmd) { struct file *f = music_find_file(path); if(f == NULL) { - g_error("couldn't find %s", path); + g_warning("couldn't find %s", path); + goto commands_get_raw_free_path; } GOutputStream *os = g_io_stream_get_output_stream((GIOStream*)connection); @@ -52,14 +53,18 @@ static void commands_get_raw(GSocketConnection *connection, const gchar *cmd) { GFileInputStream *is = g_file_read(file, NULL, &error); if(is == NULL) { - g_error(error->message); + g_warning(error->message); + g_error_free(error); + goto commands_get_raw_file_unref; } GFileInfo *fi = g_file_query_info(file, G_FILE_ATTRIBUTE_STANDARD_SIZE, G_FILE_QUERY_INFO_NONE, NULL, &error); if(fi == NULL) { - g_error(error->message); + g_warning(error->message); + g_error_free(error); + goto commands_get_raw_file_unref; } goffset filesize = g_file_info_get_size(fi); @@ -73,7 +78,10 @@ static void commands_get_raw(GSocketConnection *connection, const gchar *cmd) { if(g_output_stream_write_all(os, string->str, string->len, NULL, NULL, &error) == FALSE) { - g_error(error->message); + g_warning(error->message); + g_error_free(error); + g_string_free(string, TRUE); + goto commands_get_raw_file_unref; } g_string_free(string, TRUE); @@ -88,9 +96,13 @@ static void commands_get_raw(GSocketConnection *connection, const gchar *cmd) { g_debug("wrote %lu bytes of file data", size); } +commands_get_raw_file_unref: + g_object_unref(is); g_object_unref(file); +commands_get_raw_free_path: + g_free(path); } |