loudmouth/lm-socket.c
changeset 322 9d591fb31bc2
parent 308 7e2050a6df75
child 325 6e561a2cc542
equal deleted inserted replaced
321:d9dc997db56b 322:9d591fb31bc2
   217 socket_in_event (GIOChannel   *source,
   217 socket_in_event (GIOChannel   *source,
   218 		     GIOCondition  condition,
   218 		     GIOCondition  condition,
   219 		     LmSocket     *socket)
   219 		     LmSocket     *socket)
   220 {
   220 {
   221 	gchar     buf[IN_BUFFER_SIZE];
   221 	gchar     buf[IN_BUFFER_SIZE];
   222 	gsize     bytes_read;
   222 	gsize     bytes_read = 0;
   223 	gboolean  read_anything = FALSE;
   223 	gboolean  read_anything = FALSE;
   224 	gboolean  hangup;
   224 	gboolean  hangup = 0;
   225 	gint      reason;
   225 	gint      reason = 0;
   226 
   226 
   227 	if (!socket->io_channel) {
   227 	if (!socket->io_channel) {
   228 		return FALSE;
   228 		return FALSE;
   229 	}
   229 	}
   230 
   230 
   231 	while (socket_read_incoming (socket, buf, IN_BUFFER_SIZE, 
   231 	while ((condition & G_IO_IN) && socket_read_incoming (socket, buf, IN_BUFFER_SIZE, 
   232 				     &bytes_read, &hangup, &reason)) {
   232 				     &bytes_read, &hangup, &reason)) {
   233 		
   233 		
   234 		g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET, "\nRECV [%d]:\n", 
   234 		g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET, "\nRECV [%d]:\n", 
   235 		       (int)bytes_read);
   235 		       (int)bytes_read);
   236 		g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET, 
   236 		g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET, 
   242 		lm_verbose ("Read: %d chars\n", (int)bytes_read);
   242 		lm_verbose ("Read: %d chars\n", (int)bytes_read);
   243 
   243 
   244 		(socket->data_func) (socket, buf, socket->user_data);
   244 		(socket->data_func) (socket, buf, socket->user_data);
   245 
   245 
   246 		read_anything = TRUE;
   246 		read_anything = TRUE;
       
   247 
       
   248 		condition = g_io_channel_get_buffer_condition (socket->io_channel);
   247 	}
   249 	}
   248 
   250 
   249 	/* If we have read something, delay the hangup so that the data can be
   251 	/* If we have read something, delay the hangup so that the data can be
   250 	 * processed. */
   252 	 * processed. */
   251 	if (hangup && !read_anything) {
   253 	if (hangup && !read_anything) {