changeset 23396:47b709962aab

Only check for EAGAIN if read returned less than 0. This fixes a bug where the recv callback function would get called continuously if the server closed our connection and errno happened to be set to EAGAIN.
author Mark Doliner <mark@kingant.net>
date Mon, 30 Jun 2008 22:58:18 +0000
parents 0119f73a76da
children e1bddd9c5c88 60d3ba8c9047
files libpurple/protocols/jabber/jabber.c
diffstat 1 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/jabber.c	Sun Jun 29 01:51:59 2008 +0000
+++ b/libpurple/protocols/jabber/jabber.c	Mon Jun 30 22:58:18 2008 +0000
@@ -430,12 +430,17 @@
 			jabber_stream_init(js);
 	}
 
-	if(errno == EAGAIN)
+	if(len < 0 && errno == EAGAIN)
 		return;
-	else
+	else {
+		if (len == 0)
+			purple_debug_info("jabber", "Server closed the connection.\n");
+		else
+			purple_debug_info("jabber", "Disconnected: %s\n", g_strerror(errno));
 		purple_connection_error_reason (js->gc,
 			PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
 			_("Read Error"));
+	}
 }
 
 static void
@@ -470,9 +475,13 @@
 		jabber_parser_process(js, buf, len);
 		if(js->reinit)
 			jabber_stream_init(js);
-	} else if(errno == EAGAIN) {
+	} else if(len < 0 && errno == EAGAIN) {
 		return;
 	} else {
+		if (len == 0)
+			purple_debug_info("jabber", "Server closed the connection.\n");
+		else
+			purple_debug_info("jabber", "Disconnected: %s\n", g_strerror(errno));
 		purple_connection_error_reason (js->gc,
 			PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
 			_("Read Error"));