fixing segv
authorChristian Grothoff <christian@grothoff.org>
Mon, 11 Oct 2010 13:03:51 +0000 (13:03 +0000)
committerChristian Grothoff <christian@grothoff.org>
Mon, 11 Oct 2010 13:03:51 +0000 (13:03 +0000)
src/nat/nat.c
src/nat/upnp-commands.c
src/nat/upnp-discover.c

index 5159e0903921984f59ee7c190b1e31721397b379..74d08bd6f65eaf15de900e64d4f770e996250f0e 100644 (file)
@@ -333,10 +333,9 @@ nat_pulse (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   struct GNUNET_NAT_Handle *h = cls;
 
   /* Stop if we're already waiting for an action to complete */
+  h->pulse_timer = GNUNET_SCHEDULER_NO_TASK;
   if (h->processing)
     return;
-
-  h->pulse_timer = GNUNET_SCHEDULER_NO_TASK;
   h->old_status = get_traversal_status (h);
 
   /* Only update the protocol that has been successful until now */
@@ -361,7 +360,7 @@ nat_pulse (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 
       GNUNET_NAT_UPNP_pulse (h->upnp, h->is_enabled, GNUNET_YES);
 #if 0
-      GNUNET_NAT_NATPMP_pulse (h->natpmp, h->is_enabled, natpmp_pulse_cb, h);
+      GNUNET_NAT_NATPMP_pulse (h->natpmp, h->is_enabled, &natpmp_pulse_cb, h);
 #endif
     }
 }
@@ -417,11 +416,11 @@ GNUNET_NAT_register (struct GNUNET_SCHEDULER_Handle
   h->callback_cls = callback_cls;
   h->upnp =
     GNUNET_NAT_UPNP_init (h->sched, h->local_addr, addrlen, h->public_port,
-                          upnp_pulse_cb, h);
+                          &upnp_pulse_cb, h);
 #if 0
   h->natpmp =
     GNUNET_NAT_NATPMP_init (h->sched, h->local_addr, addrlen, h->public_port,
-                            natpmp_pulse_cb, h);
+                            &natpmp_pulse_cb, h);
 #endif
   h->pulse_timer = GNUNET_SCHEDULER_add_delayed (sched,
                                                  GNUNET_TIME_UNIT_SECONDS,
@@ -447,7 +446,8 @@ GNUNET_NAT_unregister (struct GNUNET_NAT_Handle *h)
   GNUNET_NAT_NATPMP_close (h->natpmp);
 #endif
 
-  GNUNET_SCHEDULER_cancel (h->sched, h->pulse_timer);
+  if (GNUNET_SCHEDULER_NO_TASK != h->pulse_timer)
+    GNUNET_SCHEDULER_cancel (h->sched, h->pulse_timer);
 
   GNUNET_free_non_null (h->local_addr);
   GNUNET_free_non_null (h->ext_addr);
index ddc5d94735a271a91f3c31f6df6977a8dd481f4c..09b0049680e01c3dd4e2ddf13e906f8c3e3c62e4 100644 (file)
@@ -256,7 +256,7 @@ UPNP_command_receiver (void *data,
 
   GNUNET_CONNECTION_destroy (cls->s, GNUNET_NO);
 
-  (*cls->caller_cb) (cls->buffer, cls->buf_size, cls->caller_cls);
+  cls->caller_cb (cls->buffer, cls->buf_size, cls->caller_cls);
 
   GNUNET_free (cls->content);
   GNUNET_free (cls);
@@ -415,7 +415,7 @@ UPNP_command_ (struct GNUNET_SCHEDULER_Handle *sched,
           if (soap_body + sizeof (soap_body) <= p + 100)
             {
               GNUNET_assert (GNUNET_NO);
-              (*caller_cb) (buffer, 0, caller_cls);
+              caller_cb (buffer, 0, caller_cls);
               return;
             }
           *(p++) = '<';
@@ -453,6 +453,7 @@ UPNP_command_ (struct GNUNET_SCHEDULER_Handle *sched,
     {
       GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, "UPnP",
                        "Invalid URL passed to UPNP_command(): %s\n", url);
+      caller_cb (buffer, 0, caller_cls);
       return;
     }
 
@@ -490,7 +491,7 @@ UPNP_command_ (struct GNUNET_SCHEDULER_Handle *sched,
       GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, _("%s failed at %s:%d\n"),
                        "UPnP", "inet_pton", __FILE__, __LINE__);
 
-      (*caller_cb) (buffer, 0, caller_cls);
+      caller_cb (buffer, 0, caller_cls);
       return;
     }
 
@@ -541,7 +542,7 @@ UPNP_command_ (struct GNUNET_SCHEDULER_Handle *sched,
                        __LINE__);
 #endif
 
-      (*caller_cb) (buffer, 0, caller_cls);
+      caller_cb (buffer, 0, caller_cls);
 
       GNUNET_free (content_buf);
       GNUNET_free (cls);
index 715f2fcee44df74866796ab07f73bf88f0800067..5c64d161d6c1ad0eaefab4a59b2c91a48142a4a7 100644 (file)
@@ -955,7 +955,8 @@ discover_recv (void *data, const struct GNUNET_SCHEDULER_TaskContext *tc)
                                     &addrlen);
   if (received == GNUNET_SYSERR)
     {
-      PRINT_SOCKET_ERROR ("GNUNET_NETWORK_socket_recvfrom");
+      if (errno != EAGAIN)
+       PRINT_SOCKET_ERROR ("GNUNET_NETWORK_socket_recvfrom");
     }
 #if DEBUG_UPNP
   else