diff options
-rw-r--r-- | response.c | 22 |
1 files changed, 10 insertions, 12 deletions
@@ -15,7 +15,7 @@ extern GAsyncQueue* stdinQueue; //our queue SignalObject* signalObject; //the signal object which registered the signal id //write output to client -static gssize writeOutput(GPollableOutputStream* stream, gchar* data); +static void writeOutput(GPollableOutputStream* stream, gchar* data); //callback for client output, this is where the queue messages are sent to the client gboolean cbClientOutput(gpointer data, gpointer additional) @@ -89,7 +89,7 @@ gboolean cbClientInput(gpointer data, gpointer additional) } //write output to client -static gssize writeOutput(GPollableOutputStream* stream, gchar* data) +static void writeOutput(GPollableOutputStream* stream, gchar* data) { gssize written_bytes = 0; @@ -108,9 +108,13 @@ static gssize writeOutput(GPollableOutputStream* stream, gchar* data) // strcat(out, "\n"); // } - written_bytes = g_pollable_output_stream_write_nonblocking(stream, terminated, strlen(data), NULL, NULL); + written_bytes = g_pollable_output_stream_write_nonblocking(stream, terminated, strlen(terminated), NULL, NULL); + if (written_bytes == -1) { + g_print("Could not send message to client\n"); + } + g_free (terminated); - return written_bytes; + return; } //initialize the signals @@ -132,7 +136,6 @@ void responseCb(gpointer instance, GObject *arg1, gpointer user_data) GPollableOutputStream* stream = (GPollableOutputStream*)data->outStream; gchar* str = data->data; - gssize written = 0; gchar* out = NULL; @@ -147,13 +150,8 @@ void responseCb(gpointer instance, GObject *arg1, gpointer user_data) // FIXME - Parser_main may generate multiple responses Parser_main(str, &out, 1); + data->cb(stream, out); - written = data->cb(stream, out); - if (written == -1) { - g_print("Could not send message to client\n"); - } - - g_free(out); - + g_free(out); g_static_mutex_unlock (&mutex); } |