diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2010-08-23 21:01:28 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2010-08-23 21:01:28 +0200 |
commit | 9dbb7aeb8f3cab7b6568d43da5a1913a0581a00f (patch) | |
tree | 633034d2d4f644f339f90d2e4d411cb7ff300119 | |
parent | ddecaa7bc8b82c0a51ba4c00b7e616cc6d6c7a7d (diff) |
Use a while loop for reading from the control socket.
-rw-r--r-- | control_service.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/control_service.c b/control_service.c index 9a63dfd..1dca7a9 100644 --- a/control_service.c +++ b/control_service.c @@ -17,19 +17,21 @@ static gboolean service_incoming(GSocketService *service, GSocket *socket = g_socket_connection_get_socket(connection); gchar buffer[0x400]; - gssize size = g_socket_receive(socket, buffer, 0x400, NULL, NULL); + gssize size; - gchar *pos = g_strstr_len(buffer, size, "\r"); - if(pos == NULL) { - pos = g_strstr_len(buffer, size, "\n"); - } - if(pos == NULL) { - g_warning("EOL not found"); - return FALSE; - } - *pos = '\0'; + while((size = g_socket_receive(socket, buffer, 0x400, NULL, NULL)) > 0) { + gchar *pos = g_strstr_len(buffer, size, "\r"); + if(pos == NULL) { + pos = g_strstr_len(buffer, size, "\n"); + } + if(pos == NULL) { + g_warning("EOL not found"); + return FALSE; + } + *pos = '\0'; - control_commands_handle(connection, buffer); + control_commands_handle(connection, buffer); + } return FALSE; } |