diff options
-rw-r--r-- | commands.c | 20 | ||||
-rw-r--r-- | httpd.c | 8 |
2 files changed, 20 insertions, 8 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); } @@ -16,7 +16,7 @@ static gboolean service_incoming(GSocketService *service, socket = g_socket_connection_get_socket(connection); if(socket == NULL) { - g_error("g_socket_connection_get_socket() returned NULL"); + g_warning("g_socket_connection_get_socket() returned NULL"); return FALSE; } @@ -28,8 +28,9 @@ static gboolean service_incoming(GSocketService *service, gchar buffer[0x400]; gssize len = g_socket_receive(socket, buffer, 0x400, NULL, &error); if(len == -1) { - g_error(error->message); + g_warning(error->message); g_error_free(error); + g_string_free(string, TRUE); return FALSE; } tot += len; @@ -68,9 +69,8 @@ static gboolean service_incoming(GSocketService *service, commands_handle(connection, path); if(g_socket_close(socket, &error) == FALSE) { - g_error(error->message); + g_warning(error->message); g_error_free(error); - return FALSE; } return FALSE; |