diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-05-03 11:33:00 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-05-03 11:33:00 +0000 |
commit | ed03501d4f67d8acef116c6609393cca28923cd0 (patch) | |
tree | d7a2529436be0ee117349fb74082a1217001595a /src/peerinfo-tool | |
parent | 31fa7ff21510bad20198b2e6d2b93d62d7624394 (diff) | |
download | gnunet-ed03501d4f67d8acef116c6609393cca28923cd0.tar.gz gnunet-ed03501d4f67d8acef116c6609393cca28923cd0.zip |
-applying fix based on fixed #2210
Diffstat (limited to 'src/peerinfo-tool')
-rw-r--r-- | src/peerinfo-tool/gnunet-peerinfo.c | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/src/peerinfo-tool/gnunet-peerinfo.c b/src/peerinfo-tool/gnunet-peerinfo.c index 5f9e2cefa..d450bf748 100644 --- a/src/peerinfo-tool/gnunet-peerinfo.c +++ b/src/peerinfo-tool/gnunet-peerinfo.c | |||
@@ -215,6 +215,11 @@ static struct PrintContext *pc_head; | |||
215 | */ | 215 | */ |
216 | static struct PrintContext *pc_tail; | 216 | static struct PrintContext *pc_tail; |
217 | 217 | ||
218 | /** | ||
219 | * Handle to current 'GNUNET_PEERINFO_add_peer' operation. | ||
220 | */ | ||
221 | static struct GNUNET_PEERINFO_AddContext *ac; | ||
222 | |||
218 | 223 | ||
219 | /** | 224 | /** |
220 | * Main state machine that goes over all options and | 225 | * Main state machine that goes over all options and |
@@ -665,6 +670,25 @@ add_address_to_hello (void *cls, size_t max, void *buffer) | |||
665 | 670 | ||
666 | 671 | ||
667 | /** | 672 | /** |
673 | * Continuation called from 'GNUNET_PEERINFO_add_peer' | ||
674 | * | ||
675 | * @param cls closure, NULL | ||
676 | * @param emsg error message, NULL on success | ||
677 | */ | ||
678 | static void | ||
679 | add_continuation (void *cls, | ||
680 | const char *emsg) | ||
681 | { | ||
682 | ai = NULL; | ||
683 | if (NULL != emsg) | ||
684 | fprintf (stderr, | ||
685 | _("Failure adding HELLO: %s\n"), | ||
686 | emsg); | ||
687 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); | ||
688 | } | ||
689 | |||
690 | |||
691 | /** | ||
668 | * Parse the PUT URI given at the command line and add it to our peerinfo | 692 | * Parse the PUT URI given at the command line and add it to our peerinfo |
669 | * database. | 693 | * database. |
670 | * | 694 | * |
@@ -698,16 +722,16 @@ parse_hello_uri (const char *put_uri) | |||
698 | if (NULL != hello) | 722 | if (NULL != hello) |
699 | { | 723 | { |
700 | /* WARNING: this adds the address from URI WITHOUT verification! */ | 724 | /* WARNING: this adds the address from URI WITHOUT verification! */ |
701 | if (GNUNET_OK == ctx.ret) | 725 | if (GNUNET_OK == ctx.ret) |
702 | GNUNET_PEERINFO_add_peer (peerinfo, hello, NULL, NULL); | 726 | ac = GNUNET_PEERINFO_add_peer (peerinfo, hello, NULL, NULL); |
727 | else | ||
728 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); | ||
703 | GNUNET_free (hello); | 729 | GNUNET_free (hello); |
704 | } | 730 | } |
705 | 731 | ||
706 | /* wait 1s to give peerinfo operation a chance to succeed */ | 732 | /* wait 1s to give peerinfo operation a chance to succeed */ |
707 | /* FIXME: current peerinfo API sucks to require this; not to mention | 733 | /* FIXME: current peerinfo API sucks to require this; not to mention |
708 | that we get no feedback to determine if the operation actually succeeded */ | 734 | that we get no feedback to determine if the operation actually succeeded */ |
709 | tt = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | ||
710 | &state_machine, NULL); | ||
711 | return ctx.ret; | 735 | return ctx.ret; |
712 | } | 736 | } |
713 | 737 | ||
@@ -730,6 +754,11 @@ shutdown_task (void *cls, | |||
730 | struct AddressRecord *ar; | 754 | struct AddressRecord *ar; |
731 | unsigned int i; | 755 | unsigned int i; |
732 | 756 | ||
757 | if (NULL != ac) | ||
758 | { | ||
759 | GNUNET_PEERINFO_add_peer_cancel (ac); | ||
760 | ac = NULL; | ||
761 | } | ||
733 | if (GNUNET_SCHEDULER_NO_TASK != tt) | 762 | if (GNUNET_SCHEDULER_NO_TASK != tt) |
734 | { | 763 | { |
735 | GNUNET_SCHEDULER_cancel (tt); | 764 | GNUNET_SCHEDULER_cancel (tt); |