[farsight2/master] Centralise proxymapping stopping

Olivier Crête olivier.crete at collabora.co.uk
Tue Dec 23 15:24:43 PST 2008


---
 fs-upnp-simple-igd.c |   23 +++++++++++++++++------
 1 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/fs-upnp-simple-igd.c b/fs-upnp-simple-igd.c
index e9d8bc4..568f47b 100644
--- a/fs-upnp-simple-igd.c
+++ b/fs-upnp-simple-igd.c
@@ -112,6 +112,8 @@ static void fs_upnp_simple_igd_add_proxy_mapping (FsUpnpSimpleIgd *self,
 
 static void free_proxy (struct Proxy *prox);
 
+static void stop_proxymapping (struct ProxyMapping *pm);
+
 static void
 fs_upnp_simple_igd_class_init (FsUpnpSimpleIgdClass *klass)
 {
@@ -433,8 +435,7 @@ _service_proxy_added_port_mapping (GUPnPServiceProxy *proxy,
   }
   g_clear_error (&error);
 
-  g_source_destroy (pm->timeout_src);
-  pm->timeout_src = NULL;
+  stop_proxymapping (pm);
 }
 
 static gboolean
@@ -442,10 +443,7 @@ _service_proxy_add_mapping_timeout (gpointer user_data)
 {
   struct ProxyMapping *pm = user_data;
 
-  gupnp_service_proxy_cancel_action (pm->proxy->proxy,
-      pm->action);
-  pm->action = NULL;
-  pm->timeout_src = NULL;
+  stop_proxymapping (pm);
 
   return FALSE;
 }
@@ -535,3 +533,16 @@ fs_upnp_simple_igd_remove_port (FsUpnpSimpleIgd *self,
 
   free_mapping (mapping);
 }
+
+static void
+stop_proxymapping (struct ProxyMapping *pm)
+{
+  if (pm->action)
+    gupnp_service_proxy_cancel_action (pm->proxy->proxy,
+        pm->action);
+  pm->action = NULL;
+
+  if (pm->timeout_src)
+    g_source_destroy (pm->timeout_src);
+  pm->timeout_src = NULL;
+}
-- 
1.5.6.5




More information about the farsight-commits mailing list