pidgin: 2a68f533: Fix running several Bonjour instances on...

datallah at pidgin.im datallah at pidgin.im
Fri Jul 18 20:30:38 EDT 2008


-----------------------------------------------------------------
Revision: 2a68f533ef12aaf2b26c7827857687c4ff04b229
Ancestor: c7c882ce933f14ae4b89d4c9782a84accaec53b5
Author: datallah at pidgin.im
Date: 2008-07-19T00:18:18
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/2a68f533ef12aaf2b26c7827857687c4ff04b229

Modified files:
        libpurple/protocols/bonjour/jabber.c
        libpurple/win32/libc_interface.c

ChangeLog: 

Fix running several Bonjour instances on the same machine.
The server socket had SO_REUSEADDR set, which was causing all the instances to
share the same port (and therefore it was indeterminate who would actually get
the incoming connection).
Fixes #6231

-------------- next part --------------
============================================================
--- libpurple/protocols/bonjour/jabber.c	160217d888c93ea296ba1cb8dfdaedeeb922b082
+++ libpurple/protocols/bonjour/jabber.c	abd2623f212047905d1ecb03506b9ed82eb1de5f
@@ -672,7 +672,6 @@ bonjour_jabber_start(BonjourJabber *jdat
 bonjour_jabber_start(BonjourJabber *jdata)
 {
 	struct sockaddr_in my_addr;
-	int yes = 1;
 	int i;
 	gboolean bind_successful;
 
@@ -686,16 +685,6 @@ bonjour_jabber_start(BonjourJabber *jdat
 		return -1;
 	}
 
-	/* Make the socket reusable */
-	if (setsockopt(jdata->socket, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) != 0)
-	{
-		purple_debug_error("bonjour", "Error setting socket options: %s\n", g_strerror(errno));
-		purple_connection_error_reason (jdata->account->gc,
-			PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
-			_("Error setting socket options"));
-		return -1;
-	}
-
 	memset(&my_addr, 0, sizeof(struct sockaddr_in));
 	my_addr.sin_family = AF_INET;
 
@@ -709,6 +698,8 @@ bonjour_jabber_start(BonjourJabber *jdat
 			bind_successful = TRUE;
 			break;
 		}
+
+		purple_debug_info("bonjour", "Unable to bind to port %u.(%s)\n", jdata->port, g_strerror(errno));
 		jdata->port++;
 	}
 
============================================================
--- libpurple/win32/libc_interface.c	a920cef75326d80afa195116b2dc109f565a4980
+++ libpurple/win32/libc_interface.c	957d7f22e4d82d08e6067d60007f406e91bb4325
@@ -327,9 +327,12 @@ char* wpurple_strerror(int errornum) {
 			case WSAETIMEDOUT: /* 10060 */
 				g_snprintf(errbuf, sizeof(errbuf), _("Connection timed out."));
 				break;
-			case WSAECONNREFUSED: /*10061 */
+			case WSAECONNREFUSED: /* 10061 */
 				g_snprintf(errbuf, sizeof(errbuf), _("Connection refused."));
 				break;
+			case WSAEADDRINUSE: /* 10048 */
+				g_snprintf(errbuf, sizeof(errbuf), _("Address already in use."));
+				break;
 			default:
 				g_snprintf(errbuf, sizeof(errbuf), "Windows socket error #%d", errornum);
 		}


More information about the Commits mailing list