From: Bart Polot Date: Thu, 11 Oct 2012 23:25:05 +0000 (+0000) Subject: - avoid crashing on shutdown in the middle of a test (timeout) X-Git-Tag: initial-import-from-subversion-38251~11434 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=cb0e968a1eba3d59c51b859355e32f180145c25a;p=oweals%2Fgnunet.git - avoid crashing on shutdown in the middle of a test (timeout) --- diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index acfd215fa..c58a25d23 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c @@ -205,6 +205,11 @@ struct MeshPeerInfo */ struct GNUNET_TIME_Absolute last_contact; + /** + * Task handler for delayed connect task; + */ + GNUNET_SCHEDULER_TaskIdentifier connect_task; + /** * Number of attempts to reconnect so far */ @@ -2616,6 +2621,8 @@ peer_info_connect_task (void *cls, { struct MeshPathInfo *path_info = cls; + path_info->peer->connect_task = GNUNET_SCHEDULER_NO_TASK; + if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) { GNUNET_free (cls); @@ -2663,6 +2670,10 @@ peer_info_destroy (struct MeshPeerInfo *pi) path_destroy (p); p = nextp; } + if (GNUNET_SCHEDULER_NO_TASK != pi->connect_task) + { + GNUNET_free (GNUNET_SCHEDULER_cancel (pi->connect_task)); + } GNUNET_free (pi); return GNUNET_OK; } @@ -3242,7 +3253,8 @@ tunnel_notify_client_peer_disconnected (void *cls, GNUNET_PEER_Id peer_id) path_info = GNUNET_malloc (sizeof (struct MeshPathInfo)); path_info->peer = peer; path_info->t = t; - GNUNET_SCHEDULER_add_now (&peer_info_connect_task, path_info); + peer->connect_task = GNUNET_SCHEDULER_add_now (&peer_info_connect_task, + path_info); }