# HG changeset patch # User Senko Rasic # Date 1197213706 -3600 # Node ID 9d591fb31bc202a9f1c080c9eea32223b61d3731 # Parent d9dc997db56ba82cb5feb82ea4de9d30eec1612e Make blocking reads work diff -r d9dc997db56b -r 9d591fb31bc2 loudmouth/lm-socket.c --- 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