changeset 19686:b199a9be3e95

Start watching the listener socket immediately after it's created instead of waiting until we receive confirmation from the other side that they've established a TCP connection to us. This fixes a bug where sending a file from Trillian to Pidgin would fail if the Trillian user was behind a firewall. Fixes #2976. Huge thanks to Kyryll A Mirnenko aka Mirya for basically tracking this down.
author Mark Doliner <mark@kingant.net>
date Sun, 09 Sep 2007 07:52:44 +0000
parents 5444ab83b30a
children 83dd81b7edc4
files libpurple/protocols/oscar/oscar.c libpurple/protocols/oscar/peer.c
diffstat 2 files changed, 7 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/oscar/oscar.c	Sun Sep 09 05:56:56 2007 +0000
+++ b/libpurple/protocols/oscar/oscar.c	Sun Sep 09 07:52:44 2007 +0000
@@ -2125,28 +2125,11 @@
 		}
 		else if (args->status == AIM_RENDEZVOUS_CONNECTED)
 		{
-			/* Remote user has accepted our peer request */
-			PeerConnection *conn;
-
-			conn = peer_connection_find_by_cookie(od, userinfo->sn, args->cookie);
 			/*
-			 * If conn is NULL it means we haven't tried to create
-			 * a connection with that user.  They may be trying to
-			 * do something malicious.
+			 * Remote user has accepted our peer request.  If we
+			 * wanted to we could look up the PeerConnection using
+			 * args->cookie, but we don't need to do anything here.
 			 */
-			if (conn != NULL)
-			{
-				if (conn->listenerfd != -1)
-				{
-					/*
-					 * If they are connecting directly to us then
-					 * continue the peer negotiation by
-					 * accepting connections on our listener port.
-					 */
-					conn->watcher_incoming = purple_input_add(conn->listenerfd,
-							PURPLE_INPUT_READ, peer_connection_listen_cb, conn);
-				}
-			}
 		}
 	}
 
--- a/libpurple/protocols/oscar/peer.c	Sun Sep 09 05:56:56 2007 +0000
+++ b/libpurple/protocols/oscar/peer.c	Sun Sep 09 07:52:44 2007 +0000
@@ -671,6 +671,10 @@
 	account = purple_connection_get_account(gc);
 	conn->listenerfd = listenerfd;
 
+	/* Watch for new connections on our listener socket */
+	conn->watcher_incoming = purple_input_add(conn->listenerfd,
+			PURPLE_INPUT_READ, peer_connection_listen_cb, conn);
+
 	/* Send the "please connect to me!" ICBM */
 	bos_conn = flap_connection_findbygroup(od, SNAC_FAMILY_ICBM);
 	if (bos_conn == NULL)