diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2016-05-29 11:19:50 +0000 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2016-05-29 11:19:50 +0000 |
commit | b5454a701bde16ebc577fbb87d09f5dc1ead587e (patch) | |
tree | af5eac846653e86cff5bf158a1e740459fd438e5 | |
parent | e0c01618605c1ef2901b2002aed6801858603305 (diff) | |
download | gnunet-b5454a701bde16ebc577fbb87d09f5dc1ead587e.tar.gz gnunet-b5454a701bde16ebc577fbb87d09f5dc1ead587e.zip |
- Fix #4532
-rw-r--r-- | src/fs/gnunet-service-fs_cp.c | 12 | ||||
-rw-r--r-- | src/include/gnunet_peerstore_service.h | 3 | ||||
-rw-r--r-- | src/peerstore/gnunet-service-peerstore.c | 5 | ||||
-rw-r--r-- | src/peerstore/peerstore_api.c | 8 |
4 files changed, 13 insertions, 15 deletions
diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c index 53838a542..7ec02f916 100644 --- a/src/fs/gnunet-service-fs_cp.c +++ b/src/fs/gnunet-service-fs_cp.c | |||
@@ -605,9 +605,8 @@ ats_reserve_callback (void *cls, | |||
605 | * @param cls handle to connected peer entry | 605 | * @param cls handle to connected peer entry |
606 | * @param record peerstore record information | 606 | * @param record peerstore record information |
607 | * @param emsg error message, or NULL if no errors | 607 | * @param emsg error message, or NULL if no errors |
608 | * @return #GNUNET_NO to stop iterating since we only expect 0 or 1 records | ||
609 | */ | 608 | */ |
610 | static int | 609 | static void |
611 | peer_respect_cb (void *cls, | 610 | peer_respect_cb (void *cls, |
612 | const struct GNUNET_PEERSTORE_Record *record, | 611 | const struct GNUNET_PEERSTORE_Record *record, |
613 | const char *emsg) | 612 | const char *emsg) |
@@ -615,13 +614,18 @@ peer_respect_cb (void *cls, | |||
615 | struct GSF_ConnectedPeer *cp = cls; | 614 | struct GSF_ConnectedPeer *cp = cls; |
616 | 615 | ||
617 | GNUNET_assert (NULL != cp->respect_iterate_req); | 616 | GNUNET_assert (NULL != cp->respect_iterate_req); |
618 | cp->respect_iterate_req = NULL; | 617 | printf("Got a record!\n"); |
619 | if ((NULL != record) && (sizeof (cp->disk_respect) == record->value_size)) | 618 | if ((NULL != record) && (sizeof (cp->disk_respect) == record->value_size)) |
620 | cp->disk_respect = cp->ppd.respect = *((uint32_t *)record->value); | 619 | cp->disk_respect = cp->ppd.respect = *((uint32_t *)record->value); |
621 | GSF_push_start_ (cp); | 620 | GSF_push_start_ (cp); |
622 | if (NULL != cp->creation_cb) | 621 | if (NULL != cp->creation_cb) |
623 | cp->creation_cb (cp->creation_cb_cls, cp); | 622 | cp->creation_cb (cp->creation_cb_cls, cp); |
624 | return GNUNET_NO; | 623 | if (NULL != record) |
624 | { | ||
625 | printf("Cancelling!\n"); | ||
626 | GNUNET_PEERSTORE_iterate_cancel (cp->respect_iterate_req); | ||
627 | cp->respect_iterate_req = NULL; | ||
628 | } | ||
625 | } | 629 | } |
626 | 630 | ||
627 | 631 | ||
diff --git a/src/include/gnunet_peerstore_service.h b/src/include/gnunet_peerstore_service.h index e9e344d88..97d3a3828 100644 --- a/src/include/gnunet_peerstore_service.h +++ b/src/include/gnunet_peerstore_service.h | |||
@@ -133,9 +133,8 @@ typedef void | |||
133 | * @param cls closure | 133 | * @param cls closure |
134 | * @param record peerstore record information | 134 | * @param record peerstore record information |
135 | * @param emsg error message, or NULL if no errors | 135 | * @param emsg error message, or NULL if no errors |
136 | * @return #GNUNET_YES to continue iterating, #GNUNET_NO to stop | ||
137 | */ | 136 | */ |
138 | typedef int | 137 | typedef void |
139 | (*GNUNET_PEERSTORE_Processor) (void *cls, | 138 | (*GNUNET_PEERSTORE_Processor) (void *cls, |
140 | const struct GNUNET_PEERSTORE_Record *record, | 139 | const struct GNUNET_PEERSTORE_Record *record, |
141 | const char *emsg); | 140 | const char *emsg); |
diff --git a/src/peerstore/gnunet-service-peerstore.c b/src/peerstore/gnunet-service-peerstore.c index 048201c77..af6438bb2 100644 --- a/src/peerstore/gnunet-service-peerstore.c +++ b/src/peerstore/gnunet-service-peerstore.c | |||
@@ -251,7 +251,7 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) | |||
251 | * @param emsg error message or NULL if no errors | 251 | * @param emsg error message or NULL if no errors |
252 | * @return #GNUNET_YES to continue iteration | 252 | * @return #GNUNET_YES to continue iteration |
253 | */ | 253 | */ |
254 | static int | 254 | static void |
255 | record_iterator (void *cls, const struct GNUNET_PEERSTORE_Record *record, | 255 | record_iterator (void *cls, const struct GNUNET_PEERSTORE_Record *record, |
256 | const char *emsg) | 256 | const char *emsg) |
257 | { | 257 | { |
@@ -270,7 +270,7 @@ record_iterator (void *cls, const struct GNUNET_PEERSTORE_Record *record, | |||
270 | GNUNET_SERVER_receive_done (cls_record->client, | 270 | GNUNET_SERVER_receive_done (cls_record->client, |
271 | NULL == emsg ? GNUNET_OK : GNUNET_SYSERR); | 271 | NULL == emsg ? GNUNET_OK : GNUNET_SYSERR); |
272 | PEERSTORE_destroy_record (cls_record); | 272 | PEERSTORE_destroy_record (cls_record); |
273 | return GNUNET_NO; | 273 | return; |
274 | } | 274 | } |
275 | 275 | ||
276 | srm = | 276 | srm = |
@@ -282,7 +282,6 @@ record_iterator (void *cls, const struct GNUNET_PEERSTORE_Record *record, | |||
282 | (struct GNUNET_MessageHeader *) | 282 | (struct GNUNET_MessageHeader *) |
283 | srm, GNUNET_NO); | 283 | srm, GNUNET_NO); |
284 | GNUNET_free (srm); | 284 | GNUNET_free (srm); |
285 | return GNUNET_YES; | ||
286 | } | 285 | } |
287 | 286 | ||
288 | 287 | ||
diff --git a/src/peerstore/peerstore_api.c b/src/peerstore/peerstore_api.c index f1c5ccd32..0339ff93a 100644 --- a/src/peerstore/peerstore_api.c +++ b/src/peerstore/peerstore_api.c | |||
@@ -670,7 +670,6 @@ handle_iterate_result (void *cls, const struct GNUNET_MessageHeader *msg) | |||
670 | void *callback_cls; | 670 | void *callback_cls; |
671 | uint16_t msg_type; | 671 | uint16_t msg_type; |
672 | struct GNUNET_PEERSTORE_Record *record; | 672 | struct GNUNET_PEERSTORE_Record *record; |
673 | int continue_iter; | ||
674 | 673 | ||
675 | ic = h->iterate_head; | 674 | ic = h->iterate_head; |
676 | if (NULL == ic) | 675 | if (NULL == ic) |
@@ -704,16 +703,13 @@ handle_iterate_result (void *cls, const struct GNUNET_MessageHeader *msg) | |||
704 | { | 703 | { |
705 | record = PEERSTORE_parse_record_message (msg); | 704 | record = PEERSTORE_parse_record_message (msg); |
706 | if (NULL == record) | 705 | if (NULL == record) |
707 | continue_iter = | 706 | callback (callback_cls, NULL, |
708 | callback (callback_cls, NULL, | ||
709 | _("Received a malformed response from service.")); | 707 | _("Received a malformed response from service.")); |
710 | else | 708 | else |
711 | { | 709 | { |
712 | continue_iter = callback (callback_cls, record, NULL); | 710 | callback (callback_cls, record, NULL); |
713 | PEERSTORE_destroy_record (record); | 711 | PEERSTORE_destroy_record (record); |
714 | } | 712 | } |
715 | if (GNUNET_NO == continue_iter) | ||
716 | ic->callback = NULL; | ||
717 | } | 713 | } |
718 | } | 714 | } |
719 | 715 | ||