From: Christian Grothoff Date: Thu, 20 May 2010 11:41:09 +0000 (+0000) Subject: abort start task on shutdown of connection X-Git-Tag: initial-import-from-subversion-38251~21633 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=1595c455274f5e0998a154201853f7d61336d1c2;p=oweals%2Fgnunet.git abort start task on shutdown of connection --- diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c index a04d5407d..972ff47d0 100644 --- a/src/arm/gnunet-service-arm.c +++ b/src/arm/gnunet-service-arm.c @@ -711,6 +711,7 @@ static void shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { struct ServiceList *pos; + #if DEBUG_ARM GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Stopping all services\n")); #endif diff --git a/src/arm/gnunet-service-manager.c b/src/arm/gnunet-service-manager.c index 346ee182a..43f560958 100644 --- a/src/arm/gnunet-service-manager.c +++ b/src/arm/gnunet-service-manager.c @@ -152,6 +152,11 @@ struct ForwardedConnection * Current back-off value. */ struct GNUNET_TIME_Relative back_off; + + /** + * Task that tries to initiate forwarding. + */ + GNUNET_SCHEDULER_TaskIdentifier start_task; /** * @@ -325,6 +330,9 @@ closeClientAndServiceSockets (struct ForwardedConnection *fc, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Closing forwarding connection (done with both directions)\n"); #endif + if (fc->start_task != GNUNET_SCHEDULER_NO_TASK) + GNUNET_SCHEDULER_cancel (scheduler, + fc->start_task); if ( (NULL != fc->armClientSocket) && (GNUNET_SYSERR == GNUNET_NETWORK_socket_close (fc->armClientSocket)) ) @@ -497,11 +505,13 @@ receiveFromService (void *cls, rem).value); #endif rem = GNUNET_TIME_absolute_get_remaining (fc->timeout); - GNUNET_SCHEDULER_add_delayed (scheduler, - GNUNET_TIME_relative_min (fc->back_off, - rem), - &start_forwarding, - fc); + GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == fc->start_task); + fc->start_task + = GNUNET_SCHEDULER_add_delayed (scheduler, + GNUNET_TIME_relative_min (fc->back_off, + rem), + &start_forwarding, + fc); } else { @@ -590,11 +600,13 @@ forwardToService (void *cls, rem).value); #endif rem = GNUNET_TIME_absolute_get_remaining (fc->timeout); - GNUNET_SCHEDULER_add_delayed (scheduler, - GNUNET_TIME_relative_min (fc->back_off, - rem), - &start_forwarding, - fc); + GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == fc->start_task); + fc->start_task + = GNUNET_SCHEDULER_add_delayed (scheduler, + GNUNET_TIME_relative_min (fc->back_off, + rem), + &start_forwarding, + fc); } else { @@ -703,6 +715,7 @@ start_forwarding (void *cls, struct ForwardedConnection *fc = cls; struct GNUNET_TIME_Relative rem; + fc->start_task = GNUNET_SCHEDULER_NO_TASK; if ( (NULL != tc) && (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) ) { @@ -751,11 +764,13 @@ start_forwarding (void *cls, (unsigned long long) GNUNET_TIME_relative_min (fc->back_off, rem).value); #endif - GNUNET_SCHEDULER_add_delayed (scheduler, - GNUNET_TIME_relative_min (fc->back_off, - rem), - &start_forwarding, - fc); + GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == fc->start_task); + fc->start_task + = GNUNET_SCHEDULER_add_delayed (scheduler, + GNUNET_TIME_relative_min (fc->back_off, + rem), + &start_forwarding, + fc); return; } #if DEBUG_SERVICE_MANAGER @@ -885,7 +900,11 @@ acceptConnection (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_TIME_UNIT_FOREVER_REL, fc->armClientSocket, &receiveFromClient, fc); - start_forwarding (fc, NULL); + GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == fc->start_task); + fc->start_task + = GNUNET_SCHEDULER_add_now (scheduler, + &start_forwarding, + fc); }