pidgin: 1d533ceb: Only check for EAGAIN if read returned l...

markdoliner at pidgin.im markdoliner at pidgin.im
Mon Jun 30 19:01:25 EDT 2008


-----------------------------------------------------------------
Revision: 1d533cebad7c0dbda8ec8ebee1334d27dcae5f9c
Ancestor: 4d5c3b5ef59ce60e98576ffc7edf6ebb0960fff1
Author: markdoliner at pidgin.im
Date: 2008-06-30T22:58:18
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/1d533cebad7c0dbda8ec8ebee1334d27dcae5f9c

Modified files:
        libpurple/protocols/jabber/jabber.c

ChangeLog: 

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.

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jabber.c	e98b3c84ef06f15c947b3190304799abef8f30b3
+++ libpurple/protocols/jabber/jabber.c	f005b3dede749de2f533f11c1c70a8575f2ef47a
@@ -430,12 +430,17 @@ jabber_recv_cb_ssl(gpointer data, Purple
 			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_recv_cb(gpointer data, gint sourc
 		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"));


More information about the Commits mailing list