cpw.malu.xmpp.jingle_ft: f1968787: Sets up TCP connections using local stre...

malu at pidgin.im malu at pidgin.im
Tue Mar 31 15:50:42 EDT 2009


-----------------------------------------------------------------
Revision: f19687878c8a00e4120c5612d76fb1cf6dae5bfd
Ancestor: bda2fa861fb7a944b368690b2aabb4349f9813dc
Author: malu at pidgin.im
Date: 2009-03-31T19:44:56
Branch: im.pidgin.cpw.malu.xmpp.jingle_ft
URL: http://d.pidgin.im/viewmtn/revision/info/f19687878c8a00e4120c5612d76fb1cf6dae5bfd

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

ChangeLog: 

Sets up TCP connections using local streamhosts

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jingle/s5b.c	e40aa959ddd52942228c73829313af1b7ae88e06
+++ libpurple/protocols/jabber/jingle/s5b.c	04cfaa7c4b43ba81053a72ce6b3c584195f47396
@@ -119,6 +119,7 @@ struct _JingleS5BPrivate {
 	PurpleProxyConnectData *connect_data;
 	PurpleNetworkListenData *listen_data;
 	PurpleProxyInfo *ppi;
+	int watcher;
 	GList *remote_streamhosts;
 	GList *local_streamhosts;
 	GList *remaining_streamhosts; /* pointer to untested remote SHs */
@@ -353,6 +354,40 @@ static void
 } JingleS5BConnectData;
 
 static void
+jingle_s5b_send_connected_cb(gpointer data, gint source,
+		PurpleInputCondition cond)
+{
+	JingleS5B *s5b = ((JingleS5BConnectData *) data)->s5b;
+	int acceptfd = accept(source, NULL, 0);
+	int flags;
+	
+	purple_debug_info("jingle-s5b", "in jingle_s5b_send_connected_cb\n");
+	
+	if(acceptfd == -1 && (errno == EAGAIN || errno == EWOULDBLOCK))
+		return;
+	else if(acceptfd == -1) {
+		purple_debug_warning("jingle-s5b", "accept: %s\n", g_strerror(errno));
+		/* Don't cancel the ft - allow it to fall to the next streamhost.*/
+		return;
+	}
+
+	purple_input_remove(s5b->priv->watcher);
+	close(source);
+	s5b->priv->local_fd = -1;
+
+	flags = fcntl(acceptfd, F_GETFL);
+	fcntl(acceptfd, F_SETFL, flags | O_NONBLOCK);
+#ifndef _WIN32
+	fcntl(acceptfd, F_SETFD, FD_CLOEXEC);
+#endif
+
+	/*
+	s5b->priv->watcher = purple_input_add(acceptfd, PURPLE_INPUT_READ,
+					 jingle_s5b_send_read_cb, data);
+	*/
+}
+
+static void
 jingle_s5b_listen_cb(int sock, gpointer data)
 {
 	JingleS5B *s5b = ((JingleS5BConnectData *) data)->s5b;
@@ -362,8 +397,6 @@ jingle_s5b_listen_cb(int sock, gpointer 
 	
 	JINGLE_S5B_GET_PRIVATE(s5b)->listen_data = NULL;
 	
-	g_free(data);
-	
 	if (sock > 0) {
 		guint local_port = purple_network_get_port_from_fd(sock);
 		const gchar *local_ip = purple_network_get_local_system_ip(js->fd);
@@ -391,8 +424,12 @@ jingle_s5b_listen_cb(int sock, gpointer 
 					sh);	
 		}
 
-		JINGLE_S5B_GET_PRIVATE(s5b)->local_fd = sock;
+		s5b->priv->local_fd = sock;
 		
+		/* The listener for the local proxy */
+		s5b->priv->watcher = purple_input_add(sock, PURPLE_INPUT_READ,
+			jingle_s5b_send_connected_cb, data);
+		
 		g_free(jid);
 	}
 	


More information about the Commits mailing list