From 9a5b7483dc16651bbef5aeae9791c9ccb120380a Mon Sep 17 00:00:00 2001 From: "Michael J. Chudobiak" Date: Thu, 19 Jul 2012 14:48:02 -0400 Subject: added make install; fixed echoing --- CMakeLists.txt | 3 +++ instr-client.c | 5 ++--- response.c | 41 +++++++++++++++++++++-------------------- 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d0faa1f..7f63209 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,4 +12,7 @@ add_executable(instr-client instr-client.c) target_link_libraries(instr-daemon gio-2.0 gobject-2.0 glib-2.0) target_link_libraries(instr-client gio-2.0 gobject-2.0 glib-2.0) +INSTALL(TARGETS instr-daemon instr-client + RUNTIME DESTINATION /usr/bin) + diff --git a/instr-client.c b/instr-client.c index 7298774..a80a0e3 100644 --- a/instr-client.c +++ b/instr-client.c @@ -85,9 +85,8 @@ static gboolean cbServerInput(gpointer data, gpointer additional) GPollableInputStream* inStream = (GPollableInputStream*)data; size=g_pollable_input_stream_read_nonblocking(inStream, buffer, BUFSIZE, NULL, NULL); - if(size <=0 || size == G_IO_ERROR_WOULD_BLOCK) { - terminate("Connection to server lost", -1); - } + if(size <=0) terminate("Connection to server lost", -1); + g_print("\n%s", buffer); g_print("> "); return TRUE; diff --git a/response.c b/response.c index 4a16cf3..6c93622 100644 --- a/response.c +++ b/response.c @@ -95,26 +95,27 @@ void initSignals(guint *signal) g_signal_connect (signalObject, "runEchoService", G_CALLBACK (echoCb), NULL); } -//echo 3 times and send to client one time +//send to client 3 times void echoCb(gpointer instance, GObject *arg1, gpointer user_data) { - static GStaticMutex mutex = G_STATIC_MUTEX_INIT; - g_static_mutex_lock (&mutex); - SignalObjectClass *data = (SignalObjectClass*)arg1; - GPollableOutputStream* stream = (GPollableOutputStream*)data->outStream; - gchar* str = data->data; - gssize len = data->size; - gssize written = 0; - - gchar* upper = g_ascii_strup(str, len); - int i; - for(i=0; i<3; i++) { - g_print("%s\n", upper); - } - //send response back to client - - written = data->cb(stream, upper, len); - - g_free(upper); - g_static_mutex_unlock (&mutex); + static GStaticMutex mutex = G_STATIC_MUTEX_INIT; + g_static_mutex_lock (&mutex); + SignalObjectClass *data = (SignalObjectClass*)arg1; + GPollableOutputStream* stream = (GPollableOutputStream*)data->outStream; + gchar* str = data->data; + gssize len = data->size; + gssize written = 0; + + gchar* upper = g_ascii_strup(str, len); + int i; + + for(i=0; i<3; i++) { + //send response back to client + written = data->cb(stream, upper, len); + if(written == -1) { + g_print_debug("Could not send message to client\n"); + } + } + g_free(upper); + g_static_mutex_unlock (&mutex); } -- cgit