--- a/loudmouth/lm-socket.c Sun Dec 09 15:10:12 2007 +0100
+++ b/loudmouth/lm-socket.c Sun Dec 09 16:21:46 2007 +0100
@@ -219,16 +219,16 @@
LmSocket *socket)
{
gchar buf[IN_BUFFER_SIZE];
- gsize bytes_read;
+ gsize bytes_read = 0;
gboolean read_anything = FALSE;
- gboolean hangup;
- gint reason;
+ gboolean hangup = 0;
+ gint reason = 0;
if (!socket->io_channel) {
return FALSE;
}
- while (socket_read_incoming (socket, buf, IN_BUFFER_SIZE,
+ while ((condition & G_IO_IN) && socket_read_incoming (socket, buf, IN_BUFFER_SIZE,
&bytes_read, &hangup, &reason)) {
g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET, "\nRECV [%d]:\n",
@@ -244,6 +244,8 @@
(socket->data_func) (socket, buf, socket->user_data);
read_anything = TRUE;
+
+ condition = g_io_channel_get_buffer_condition (socket->io_channel);
}
/* If we have read something, delay the hangup so that the data can be