diff options
author | Michael J. Chudobiak <mjc@avtechpulse.com> | 2012-08-13 20:14:49 -0400 |
---|---|---|
committer | Michael J. Chudobiak <mjc@avtechpulse.com> | 2012-08-13 20:14:49 -0400 |
commit | a89f9159b155f04daddd51b6cf1a7d021af67ba2 (patch) | |
tree | 04450ec6d0c691d14f794bfa22a55a54a7362820 /response.c | |
parent | 17f1a001386bf5072009556757c05b2c952c92e1 (diff) |
wrong str length used in output
Diffstat (limited to 'response.c')
-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); } |