diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-07-11 14:35:44 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-07-11 14:35:44 +0000 |
commit | c7c9e6915281826e3027bc215ddffb14c2a72e47 (patch) | |
tree | a68cc6bcdb37aaca1f40653e381ae9bda6a25f35 /src/nat/nat_mini.c | |
parent | 9d360141d21175b260815e9330d60b1dbc96ef44 (diff) | |
download | gnunet-c7c9e6915281826e3027bc215ddffb14c2a72e47.tar.gz gnunet-c7c9e6915281826e3027bc215ddffb14c2a72e47.zip |
proper cleanup
Diffstat (limited to 'src/nat/nat_mini.c')
-rw-r--r-- | src/nat/nat_mini.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/nat/nat_mini.c b/src/nat/nat_mini.c index be8f63f66..c8ac65edb 100644 --- a/src/nat/nat_mini.c +++ b/src/nat/nat_mini.c | |||
@@ -399,7 +399,7 @@ process_map_output (void *cls, | |||
399 | * @param is_tcp GNUNET_YES to map TCP, GNUNET_NO for UDP | 399 | * @param is_tcp GNUNET_YES to map TCP, GNUNET_NO for UDP |
400 | * @param ac function to call with mapping result | 400 | * @param ac function to call with mapping result |
401 | * @param ac_cls closure for 'ac' | 401 | * @param ac_cls closure for 'ac' |
402 | * @return NULL on error | 402 | * @return NULL on error (no 'upnpc' installed) |
403 | */ | 403 | */ |
404 | struct GNUNET_NAT_MiniHandle * | 404 | struct GNUNET_NAT_MiniHandle * |
405 | GNUNET_NAT_mini_map_start (uint16_t port, | 405 | GNUNET_NAT_mini_map_start (uint16_t port, |
@@ -410,6 +410,9 @@ GNUNET_NAT_mini_map_start (uint16_t port, | |||
410 | struct GNUNET_NAT_MiniHandle *ret; | 410 | struct GNUNET_NAT_MiniHandle *ret; |
411 | char pstr[6]; | 411 | char pstr[6]; |
412 | 412 | ||
413 | if (GNUNET_SYSERR == | ||
414 | GNUNET_OS_check_helper_binary ("upnpc")) | ||
415 | return NULL; | ||
413 | ret = GNUNET_malloc (sizeof (struct GNUNET_NAT_MiniHandle)); | 416 | ret = GNUNET_malloc (sizeof (struct GNUNET_NAT_MiniHandle)); |
414 | ret->ac = ac; | 417 | ret->ac = ac; |
415 | ret->ac_cls = ac_cls; | 418 | ret->ac_cls = ac_cls; |
@@ -474,16 +477,6 @@ GNUNET_NAT_mini_map_stop (struct GNUNET_NAT_MiniHandle *mini) | |||
474 | { | 477 | { |
475 | char pstr[6]; | 478 | char pstr[6]; |
476 | 479 | ||
477 | if (! mini->did_map) | ||
478 | { | ||
479 | if (mini->map_cmd != NULL) | ||
480 | { | ||
481 | GNUNET_OS_command_stop (mini->map_cmd); | ||
482 | mini->map_cmd = NULL; | ||
483 | } | ||
484 | GNUNET_free (mini); | ||
485 | return; | ||
486 | } | ||
487 | if (GNUNET_SCHEDULER_NO_TASK != mini->refresh_task) | 480 | if (GNUNET_SCHEDULER_NO_TASK != mini->refresh_task) |
488 | { | 481 | { |
489 | GNUNET_SCHEDULER_cancel (mini->refresh_task); | 482 | GNUNET_SCHEDULER_cancel (mini->refresh_task); |
@@ -494,6 +487,16 @@ GNUNET_NAT_mini_map_stop (struct GNUNET_NAT_MiniHandle *mini) | |||
494 | GNUNET_OS_command_stop (mini->refresh_cmd); | 487 | GNUNET_OS_command_stop (mini->refresh_cmd); |
495 | mini->refresh_cmd = NULL; | 488 | mini->refresh_cmd = NULL; |
496 | } | 489 | } |
490 | if (! mini->did_map) | ||
491 | { | ||
492 | if (mini->map_cmd != NULL) | ||
493 | { | ||
494 | GNUNET_OS_command_stop (mini->map_cmd); | ||
495 | mini->map_cmd = NULL; | ||
496 | } | ||
497 | GNUNET_free (mini); | ||
498 | return; | ||
499 | } | ||
497 | mini->ac (mini->ac_cls, GNUNET_NO, | 500 | mini->ac (mini->ac_cls, GNUNET_NO, |
498 | (const struct sockaddr*) &mini->current_addr, | 501 | (const struct sockaddr*) &mini->current_addr, |
499 | sizeof (mini->current_addr)); | 502 | sizeof (mini->current_addr)); |