From a89f9159b155f04daddd51b6cf1a7d021af67ba2 Mon Sep 17 00:00:00 2001 From: "Michael J. Chudobiak" Date: Mon, 13 Aug 2012 20:14:49 -0400 Subject: wrong str length used in output --- response.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'response.c') diff --git a/response.c b/response.c index abd4054..d49baad 100644 --- a/response.c +++ b/response.c @@ -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); } -- cgit