diff options
author | Florian Dold <florian.dold@gmail.com> | 2013-11-27 11:43:12 +0000 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2013-11-27 11:43:12 +0000 |
commit | dc0c2d4477859fa97fb5642e37003aef5578dc74 (patch) | |
tree | 7380d866ec509948bd2efbf65203ecc03ca3203a | |
parent | 794bcbefaf5093869f68e3d22f9502676121d328 (diff) | |
download | gnunet-dc0c2d4477859fa97fb5642e37003aef5578dc74.tar.gz gnunet-dc0c2d4477859fa97fb5642e37003aef5578dc74.zip |
- fixed use after free due to uncanceled task
-rw-r--r-- | src/set/set_api.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/set/set_api.c b/src/set/set_api.c index 54a5767e2..908fa1a1d 100644 --- a/src/set/set_api.c +++ b/src/set/set_api.c | |||
@@ -200,6 +200,11 @@ struct GNUNET_SET_ListenHandle | |||
200 | * Time to wait until we try to reconnect on failure. | 200 | * Time to wait until we try to reconnect on failure. |
201 | */ | 201 | */ |
202 | struct GNUNET_TIME_Relative reconnect_backoff; | 202 | struct GNUNET_TIME_Relative reconnect_backoff; |
203 | |||
204 | /** | ||
205 | * Task for reconnecting when the listener fails. | ||
206 | */ | ||
207 | GNUNET_SCHEDULER_TaskIdentifier reconnect_task; | ||
203 | }; | 208 | }; |
204 | 209 | ||
205 | 210 | ||
@@ -357,7 +362,7 @@ handle_client_listener_error (void *cls, enum GNUNET_MQ_Error error) | |||
357 | GNUNET_MQ_destroy (lh->mq); | 362 | GNUNET_MQ_destroy (lh->mq); |
358 | lh->mq = NULL; | 363 | lh->mq = NULL; |
359 | 364 | ||
360 | GNUNET_SCHEDULER_add_delayed (lh->reconnect_backoff, listen_connect, lh); | 365 | lh->reconnect_task = GNUNET_SCHEDULER_add_delayed (lh->reconnect_backoff, listen_connect, lh); |
361 | lh->reconnect_backoff = GNUNET_TIME_STD_BACKOFF (lh->reconnect_backoff); | 366 | lh->reconnect_backoff = GNUNET_TIME_STD_BACKOFF (lh->reconnect_backoff); |
362 | } | 367 | } |
363 | 368 | ||
@@ -651,6 +656,14 @@ listen_connect (void *cls, | |||
651 | GNUNET_MQ_HANDLERS_END | 656 | GNUNET_MQ_HANDLERS_END |
652 | }; | 657 | }; |
653 | 658 | ||
659 | if ((tc != NULL) &&(tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | ||
660 | { | ||
661 | LOG (GNUNET_ERROR_TYPE_DEBUG, "listener not reconnecting due to shutdown\n"); | ||
662 | return; | ||
663 | } | ||
664 | |||
665 | lh->reconnect_task = GNUNET_SCHEDULER_NO_TASK; | ||
666 | |||
654 | GNUNET_assert (NULL == lh->client); | 667 | GNUNET_assert (NULL == lh->client); |
655 | lh->client = GNUNET_CLIENT_connect ("set", lh->cfg); | 668 | lh->client = GNUNET_CLIENT_connect ("set", lh->cfg); |
656 | if (NULL == lh->client) | 669 | if (NULL == lh->client) |
@@ -722,6 +735,11 @@ GNUNET_SET_listen_cancel (struct GNUNET_SET_ListenHandle *lh) | |||
722 | GNUNET_CLIENT_disconnect (lh->client); | 735 | GNUNET_CLIENT_disconnect (lh->client); |
723 | lh->client = NULL; | 736 | lh->client = NULL; |
724 | } | 737 | } |
738 | if (GNUNET_SCHEDULER_NO_TASK != lh->reconnect_task) | ||
739 | { | ||
740 | GNUNET_SCHEDULER_cancel (lh->reconnect_task); | ||
741 | lh->reconnect_task = GNUNET_SCHEDULER_NO_TASK; | ||
742 | } | ||
725 | GNUNET_free (lh); | 743 | GNUNET_free (lh); |
726 | } | 744 | } |
727 | 745 | ||