diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-10-02 20:47:18 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-10-02 20:47:18 +0000 |
commit | 6a34f8a03004e15e28e7ac11261ab9585e223b75 (patch) | |
tree | 2d4d8c2c68f65ad43e497261a7fab574d6fe8302 /src/util/helper.c | |
parent | fd21090988d0cc5f451163a752240ed3476d74b5 (diff) | |
download | gnunet-6a34f8a03004e15e28e7ac11261ab9585e223b75.tar.gz gnunet-6a34f8a03004e15e28e7ac11261ab9585e223b75.zip |
-fix helper: properly abort pending write tasks during helper destroy
Diffstat (limited to 'src/util/helper.c')
-rw-r--r-- | src/util/helper.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/util/helper.c b/src/util/helper.c index 4187b819c..c9523f203 100644 --- a/src/util/helper.c +++ b/src/util/helper.c | |||
@@ -270,8 +270,8 @@ GNUNET_HELPER_wait (struct GNUNET_HELPER_Handle *h) | |||
270 | * Stop the helper process, we're closing down or had an error. | 270 | * Stop the helper process, we're closing down or had an error. |
271 | * | 271 | * |
272 | * @param h handle to the helper process | 272 | * @param h handle to the helper process |
273 | * @param soft_kill if GNUNET_YES, signals termination by closing the helper's | 273 | * @param soft_kill if #GNUNET_YES, signals termination by closing the helper's |
274 | * stdin; GNUNET_NO to signal termination by sending SIGTERM to helper | 274 | * stdin; #GNUNET_NO to signal termination by sending SIGTERM to helper |
275 | */ | 275 | */ |
276 | static void | 276 | static void |
277 | stop_helper (struct GNUNET_HELPER_Handle *h, int soft_kill) | 277 | stop_helper (struct GNUNET_HELPER_Handle *h, int soft_kill) |
@@ -512,7 +512,22 @@ void | |||
512 | GNUNET_HELPER_destroy (struct GNUNET_HELPER_Handle *h) | 512 | GNUNET_HELPER_destroy (struct GNUNET_HELPER_Handle *h) |
513 | { | 513 | { |
514 | unsigned int c; | 514 | unsigned int c; |
515 | struct GNUNET_HELPER_SendHandle *sh; | ||
515 | 516 | ||
517 | if (GNUNET_SCHEDULER_NO_TASK != h->write_task) | ||
518 | { | ||
519 | GNUNET_SCHEDULER_cancel (h->write_task); | ||
520 | h->write_task = GNUNET_SCHEDULER_NO_TASK; | ||
521 | } | ||
522 | while (NULL != (sh = h->sh_head)) | ||
523 | { | ||
524 | GNUNET_CONTAINER_DLL_remove (h->sh_head, | ||
525 | h->sh_tail, | ||
526 | sh); | ||
527 | if (NULL != sh->cont) | ||
528 | sh->cont (sh->cont_cls, GNUNET_SYSERR); | ||
529 | GNUNET_free (sh); | ||
530 | } | ||
516 | GNUNET_SERVER_mst_destroy (h->mst); | 531 | GNUNET_SERVER_mst_destroy (h->mst); |
517 | GNUNET_free (h->binary_name); | 532 | GNUNET_free (h->binary_name); |
518 | for (c = 0; h->binary_argv[c] != NULL; c++) | 533 | for (c = 0; h->binary_argv[c] != NULL; c++) |
@@ -667,12 +682,12 @@ GNUNET_HELPER_send_cancel (struct GNUNET_HELPER_SendHandle *sh) | |||
667 | if (0 == sh->wpos) | 682 | if (0 == sh->wpos) |
668 | { | 683 | { |
669 | GNUNET_CONTAINER_DLL_remove (h->sh_head, h->sh_tail, sh); | 684 | GNUNET_CONTAINER_DLL_remove (h->sh_head, h->sh_tail, sh); |
685 | GNUNET_free (sh); | ||
670 | if (NULL == h->sh_head) | 686 | if (NULL == h->sh_head) |
671 | { | 687 | { |
672 | GNUNET_SCHEDULER_cancel (h->write_task); | 688 | GNUNET_SCHEDULER_cancel (h->write_task); |
673 | h->write_task = GNUNET_SCHEDULER_NO_TASK; | 689 | h->write_task = GNUNET_SCHEDULER_NO_TASK; |
674 | } | 690 | } |
675 | GNUNET_free (sh); | ||
676 | } | 691 | } |
677 | } | 692 | } |
678 | 693 | ||