From 96219e61dcde38486e7f5a0c2d4f6927c47e9296 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 11 Oct 2010 13:03:51 +0000 Subject: fixing segv --- src/nat/nat.c | 12 ++++++------ src/nat/upnp-commands.c | 9 +++++---- src/nat/upnp-discover.c | 3 ++- 3 files changed, 13 insertions(+), 11 deletions(-) (limited to 'src/nat') diff --git a/src/nat/nat.c b/src/nat/nat.c index 5159e0903..74d08bd6f 100644 --- a/src/nat/nat.c +++ b/src/nat/nat.c @@ -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); diff --git a/src/nat/upnp-commands.c b/src/nat/upnp-commands.c index ddc5d9473..09b004968 100644 --- a/src/nat/upnp-commands.c +++ b/src/nat/upnp-commands.c @@ -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); diff --git a/src/nat/upnp-discover.c b/src/nat/upnp-discover.c index 715f2fcee..5c64d161d 100644 --- a/src/nat/upnp-discover.c +++ b/src/nat/upnp-discover.c @@ -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 -- cgit v1.2.3