changeset 25573:f1de4ccc433e

Proper error handling for p2p connections
author Sulabh Mahajan <sulabh@soc.pidgin.im>
date Sat, 14 Jun 2008 08:53:43 +0000
parents 11e2d8a878b0
children d11d1ac96a0d
files libpurple/protocols/yahoo/yahoo.c
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/yahoo/yahoo.c	Fri Jun 13 11:04:13 2008 +0000
+++ b/libpurple/protocols/yahoo/yahoo.c	Sat Jun 14 08:53:43 2008 +0000
@@ -2299,16 +2299,23 @@
 	if(!(user_data = data))
 		return ;
 
-	if((len = read(source, buf, sizeof(buf))) <= 0 )	{
-		purple_debug_warning("yahoo","p2p: Error in connection to p2p host or host disconnected\n");
+	len = read(source, buf, sizeof(buf));
+
+	if ((len < 0) && ((errno == EAGAIN) || (errno == EWOULDBLOCK)))
+		return ; /* No Worries*/
+
+	else if (len <= 0)
+	{
+		purple_debug_warning("yahoo","p2p: Error in connection, or host disconnected\n");
 		purple_input_remove(user_data->input_event);
 		close(source);
 		/*free user data*/
 		g_free(user_data->host_ip);
 		g_free(user_data->host_username);
 		g_free(user_data);
+		return;
 	}
-
+	
 	if(len < YAHOO_PACKET_HDRLEN)
 		return;