aboutsummaryrefslogtreecommitdiff
path: root/src/util/helper.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-10-02 20:56:46 +0000
committerChristian Grothoff <christian@grothoff.org>2013-10-02 20:56:46 +0000
commit18b62beec7902acecaad00c0470f2f1d4d98b244 (patch)
treed07c8f659f6fc83754b072a07bc2303ba5fafd96 /src/util/helper.c
parent0452911c66bfbd8852eea27d90108be97aa84982 (diff)
downloadgnunet-18b62beec7902acecaad00c0470f2f1d4d98b244.tar.gz
gnunet-18b62beec7902acecaad00c0470f2f1d4d98b244.zip
-do cancel read task as well
Diffstat (limited to 'src/util/helper.c')
-rw-r--r--src/util/helper.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/util/helper.c b/src/util/helper.c
index 0da702876..9037660a8 100644
--- a/src/util/helper.c
+++ b/src/util/helper.c
@@ -169,10 +169,11 @@ struct GNUNET_HELPER_Handle
169 * @param h the helper handle 169 * @param h the helper handle
170 * @param soft_kill if GNUNET_YES, signals termination by closing the helper's 170 * @param soft_kill if GNUNET_YES, signals termination by closing the helper's
171 * stdin; GNUNET_NO to signal termination by sending SIGTERM to helper 171 * stdin; GNUNET_NO to signal termination by sending SIGTERM to helper
172 * @return GNUNET_OK on success; GNUNET_SYSERR on error 172 * @return #GNUNET_OK on success; #GNUNET_SYSERR on error
173 */ 173 */
174int 174int
175GNUNET_HELPER_kill (struct GNUNET_HELPER_Handle *h, int soft_kill) 175GNUNET_HELPER_kill (struct GNUNET_HELPER_Handle *h,
176 int soft_kill)
176{ 177{
177 struct GNUNET_HELPER_SendHandle *sh; 178 struct GNUNET_HELPER_SendHandle *sh;
178 int ret; 179 int ret;
@@ -191,6 +192,11 @@ GNUNET_HELPER_kill (struct GNUNET_HELPER_Handle *h, int soft_kill)
191 GNUNET_SCHEDULER_cancel (h->restart_task); 192 GNUNET_SCHEDULER_cancel (h->restart_task);
192 h->restart_task = GNUNET_SCHEDULER_NO_TASK; 193 h->restart_task = GNUNET_SCHEDULER_NO_TASK;
193 } 194 }
195 if (GNUNET_SCHEDULER_NO_TASK != h->read_task)
196 {
197 GNUNET_SCHEDULER_cancel (h->read_task);
198 h->read_task = GNUNET_SCHEDULER_NO_TASK;
199 }
194 if (NULL == h->helper_proc) 200 if (NULL == h->helper_proc)
195 return GNUNET_SYSERR; 201 return GNUNET_SYSERR;
196 if (GNUNET_YES == soft_kill) 202 if (GNUNET_YES == soft_kill)
@@ -214,7 +220,7 @@ GNUNET_HELPER_kill (struct GNUNET_HELPER_Handle *h, int soft_kill)
214 * calling this function 220 * calling this function
215 * 221 *
216 * @param h the helper handle 222 * @param h the helper handle
217 * @return GNUNET_OK on success; GNUNET_SYSERR on error 223 * @return #GNUNET_OK on success; #GNUNET_SYSERR on error
218 */ 224 */
219int 225int
220GNUNET_HELPER_wait (struct GNUNET_HELPER_Handle *h) 226GNUNET_HELPER_wait (struct GNUNET_HELPER_Handle *h)
@@ -274,7 +280,8 @@ GNUNET_HELPER_wait (struct GNUNET_HELPER_Handle *h)
274 * stdin; #GNUNET_NO to signal termination by sending SIGTERM to helper 280 * stdin; #GNUNET_NO to signal termination by sending SIGTERM to helper
275 */ 281 */
276static void 282static void
277stop_helper (struct GNUNET_HELPER_Handle *h, int soft_kill) 283stop_helper (struct GNUNET_HELPER_Handle *h,
284 int soft_kill)
278{ 285{
279 if (GNUNET_SCHEDULER_NO_TASK != h->restart_task) 286 if (GNUNET_SCHEDULER_NO_TASK != h->restart_task)
280 { 287 {
@@ -519,6 +526,8 @@ GNUNET_HELPER_destroy (struct GNUNET_HELPER_Handle *h)
519 GNUNET_SCHEDULER_cancel (h->write_task); 526 GNUNET_SCHEDULER_cancel (h->write_task);
520 h->write_task = GNUNET_SCHEDULER_NO_TASK; 527 h->write_task = GNUNET_SCHEDULER_NO_TASK;
521 } 528 }
529 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == h->read_task);
530 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == h->restart_task);
522 while (NULL != (sh = h->sh_head)) 531 while (NULL != (sh = h->sh_head))
523 { 532 {
524 GNUNET_CONTAINER_DLL_remove (h->sh_head, 533 GNUNET_CONTAINER_DLL_remove (h->sh_head,
@@ -545,7 +554,8 @@ GNUNET_HELPER_destroy (struct GNUNET_HELPER_Handle *h)
545 * stdin; #GNUNET_NO to signal termination by sending SIGTERM to helper 554 * stdin; #GNUNET_NO to signal termination by sending SIGTERM to helper
546 */ 555 */
547void 556void
548GNUNET_HELPER_stop (struct GNUNET_HELPER_Handle *h, int soft_kill) 557GNUNET_HELPER_stop (struct GNUNET_HELPER_Handle *h,
558 int soft_kill)
549{ 559{
550 h->exp_cb = NULL; 560 h->exp_cb = NULL;
551 stop_helper (h, soft_kill); 561 stop_helper (h, soft_kill);