diff options
author | Michael J. Chudobiak <mjc@avtechpulse.com> | 2012-07-19 15:42:23 -0400 |
---|---|---|
committer | Michael J. Chudobiak <mjc@avtechpulse.com> | 2012-07-19 15:42:23 -0400 |
commit | 0fbcb784478e0be2fd7f31f79db45571fdbaef78 (patch) | |
tree | 7ea132fe5d2f1179622391686ad828789bfc34e7 | |
parent | 31bca4f44d92b6ca0e67f355f46791270a9c471d (diff) | |
parent | 9a5b7483dc16651bbef5aeae9791c9ccb120380a (diff) |
Merge branch 'master' of ulmo:Instrument
-rw-r--r-- | CMakeLists.txt | 3 | ||||
-rw-r--r-- | instr-client.c | 5 | ||||
-rw-r--r-- | 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; @@ -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); } |