pidgin: 03bc7133: Remove port mappings from the hash table...

malu at pidgin.im malu at pidgin.im
Wed Jun 17 14:20:34 EDT 2009


-----------------------------------------------------------------
Revision: 03bc71337ba702a5e373ff9c8b8443949d3706e5
Ancestor: 47f25059666d286ddfefc874f5486360935d8c2a
Author: malu at pidgin.im
Date: 2009-06-17T18:14:51
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/03bc71337ba702a5e373ff9c8b8443949d3706e5

Modified files:
        libpurple/network.c

ChangeLog: 

Remove port mappings from the hash tables when removing them.
Actually add NAT-PMP mappings to their hash table

-------------- next part --------------
============================================================
--- libpurple/network.c	2a904f7c2e877f1dbc295fd3d64cceba6d19036a
+++ libpurple/network.c	9dbf78425bad604610fc86ca3c2d91d2c6167c9f
@@ -283,9 +283,16 @@ purple_network_finish_pmp_map_cb(gpointe
 purple_network_finish_pmp_map_cb(gpointer data)
 {
 	PurpleNetworkListenData *listen_data;
+	gint *key = g_new(gint, 1);
+	gint *value = g_new(gint, 1);
 
 	listen_data = data;
 
+	/* add port mapping to hash table */
+	*key = purple_network_get_port_from_fd(listen_data->listenfd);
+	*value = listen_data->socket_type;
+	g_hash_table_insert(nat_pmp_port_mappings, key, value);
+
 	if (listen_data->cb)
 		listen_data->cb(listen_data->listenfd, listen_data->cb_data);
 
@@ -925,6 +932,7 @@ purple_network_upnp_mapping_remove(gpoin
 	purple_upnp_remove_port_mapping(port, 
 		protocol == SOCK_STREAM ? "TCP" : "UDP", 
 		purple_network_upnp_mapping_remove_cb, NULL);
+	g_hash_table_remove(upnp_port_mappings, key);
 }
 
 static void
@@ -938,6 +946,7 @@ purple_network_nat_pmp_mapping_remove(gp
 	purple_pmp_destroy_map(
 		protocol == SOCK_STREAM ? PURPLE_PMP_TYPE_TCP : PURPLE_PMP_TYPE_UDP, 
 		port);
+	g_hash_table_remove(nat_pmp_port_mappings, key);
 }
 
 void


More information about the Commits mailing list