diff options
-rw-r--r-- | src/rps/gnunet-service-rps.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c index 760ba47b6..9620ba7a8 100644 --- a/src/rps/gnunet-service-rps.c +++ b/src/rps/gnunet-service-rps.c | |||
@@ -170,6 +170,11 @@ struct PeerContext | |||
170 | struct GNUNET_CADET_TransmitHandle *is_live_task; | 170 | struct GNUNET_CADET_TransmitHandle *is_live_task; |
171 | 171 | ||
172 | /** | 172 | /** |
173 | * Identity of the peer | ||
174 | */ | ||
175 | struct GNUNET_PeerIdentity peer_id; | ||
176 | |||
177 | /** | ||
173 | * This is pobably followed by 'statistical' data (when we first saw | 178 | * This is pobably followed by 'statistical' data (when we first saw |
174 | * him, how did we get his ID, how many pushes (in a timeinterval), | 179 | * him, how did we get his ID, how many pushes (in a timeinterval), |
175 | * ...) | 180 | * ...) |
@@ -497,9 +502,10 @@ hist_update (void *cls, struct GNUNET_PeerIdentity *ids, uint32_t num_peers) | |||
497 | * This is given to ntfy_tmt_rdy and called when the channel was | 502 | * This is given to ntfy_tmt_rdy and called when the channel was |
498 | * successfully established. | 503 | * successfully established. |
499 | */ | 504 | */ |
500 | size_t | 505 | static size_t |
501 | peer_is_live (void *cls, size_t size, void *buf) | 506 | peer_is_live (void *cls, size_t size, void *buf) |
502 | { | 507 | { |
508 | struct PeerContext *ctx = cls; | ||
503 | struct GNUNET_PeerIdentity *peer; | 509 | struct GNUNET_PeerIdentity *peer; |
504 | struct PeerContext *peer_ctx; | 510 | struct PeerContext *peer_ctx; |
505 | 511 | ||
@@ -507,7 +513,8 @@ peer_is_live (void *cls, size_t size, void *buf) | |||
507 | // 0 == size) | 513 | // 0 == size) |
508 | // TODO check | 514 | // TODO check |
509 | 515 | ||
510 | peer = (struct GNUNET_PeerIdentity *) cls; | 516 | ctx->is_live_task = NULL; |
517 | peer = &ctx->peer_id; | ||
511 | peer_ctx = get_peer_ctx (peer_map, peer); | 518 | peer_ctx = get_peer_ctx (peer_map, peer); |
512 | peer_ctx->peer_flags |= LIVING; | 519 | peer_ctx->peer_flags |= LIVING; |
513 | 520 | ||
@@ -522,8 +529,6 @@ peer_is_live (void *cls, size_t size, void *buf) | |||
522 | GNUNET_array_grow (peer_ctx->outstanding_ops, peer_ctx->num_outstanding_ops, 0); | 529 | GNUNET_array_grow (peer_ctx->outstanding_ops, peer_ctx->num_outstanding_ops, 0); |
523 | } | 530 | } |
524 | 531 | ||
525 | GNUNET_free (peer); | ||
526 | |||
527 | //if (NULL != peer_ctx->is_live_task) | 532 | //if (NULL != peer_ctx->is_live_task) |
528 | //{ | 533 | //{ |
529 | // GNUNET_CADET_notify_transmit_ready_cancel (peer_ctx->is_live_task); | 534 | // GNUNET_CADET_notify_transmit_ready_cancel (peer_ctx->is_live_task); |
@@ -541,7 +546,6 @@ get_channel (struct GNUNET_CONTAINER_MultiPeerMap *peer_map, | |||
541 | const struct GNUNET_PeerIdentity *peer) | 546 | const struct GNUNET_PeerIdentity *peer) |
542 | { | 547 | { |
543 | struct PeerContext *ctx; | 548 | struct PeerContext *ctx; |
544 | struct GNUNET_PeerIdentity *tmp_peer; | ||
545 | 549 | ||
546 | ctx = get_peer_ctx (peer_map, peer); | 550 | ctx = get_peer_ctx (peer_map, peer); |
547 | if (NULL == ctx->send_channel) | 551 | if (NULL == ctx->send_channel) |
@@ -552,11 +556,12 @@ get_channel (struct GNUNET_CONTAINER_MultiPeerMap *peer_map, | |||
552 | 556 | ||
553 | if (NULL == ctx->recv_channel) | 557 | if (NULL == ctx->recv_channel) |
554 | { | 558 | { |
555 | tmp_peer = GNUNET_new (struct GNUNET_PeerIdentity); | 559 | ctx->peer_id = *peer; |
556 | *tmp_peer = *peer; | 560 | ctx->is_live_task = |
557 | ctx->is_live_task = GNUNET_CADET_notify_transmit_ready (ctx->send_channel, GNUNET_NO, | 561 | GNUNET_CADET_notify_transmit_ready (ctx->send_channel, GNUNET_NO, |
558 | GNUNET_TIME_UNIT_FOREVER_REL, | 562 | GNUNET_TIME_UNIT_FOREVER_REL, |
559 | 0, peer_is_live, tmp_peer); | 563 | sizeof (struct GNUNET_MessageHeader), |
564 | peer_is_live, ctx); | ||
560 | } | 565 | } |
561 | 566 | ||
562 | // do I have to explicitly put it in the peer_map? | 567 | // do I have to explicitly put it in the peer_map? |
@@ -1429,14 +1434,17 @@ shutdown_task (void *cls, | |||
1429 | } | 1434 | } |
1430 | 1435 | ||
1431 | 1436 | ||
1437 | /* FIXME instead of this, destroy every known channel */ | ||
1438 | { | ||
1432 | if (GNUNET_SYSERR == GNUNET_CONTAINER_multipeermap_iterate (peer_map, peer_remove_cb, NULL)) | 1439 | if (GNUNET_SYSERR == GNUNET_CONTAINER_multipeermap_iterate (peer_map, peer_remove_cb, NULL)) |
1433 | LOG (GNUNET_ERROR_TYPE_WARNING, | 1440 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1434 | "Iterating over peers to disconnect from them was cancelled\n"); | 1441 | "Iterating over peers to disconnect from them was cancelled\n"); |
1435 | 1442 | } | |
1436 | GNUNET_CONTAINER_multipeermap_destroy (peer_map); | ||
1437 | 1443 | ||
1438 | GNUNET_NSE_disconnect (nse); | 1444 | GNUNET_NSE_disconnect (nse); |
1439 | GNUNET_CADET_disconnect (cadet_handle); | 1445 | GNUNET_CADET_disconnect (cadet_handle); |
1446 | GNUNET_break (0 == GNUNET_CONTAINER_multipeermap_size (peer_map)); | ||
1447 | GNUNET_CONTAINER_multipeermap_destroy (peer_map); | ||
1440 | RPS_sampler_destroy (); | 1448 | RPS_sampler_destroy (); |
1441 | GNUNET_array_grow (request_deltas, request_deltas_size, 0); | 1449 | GNUNET_array_grow (request_deltas, request_deltas_size, 0); |
1442 | GNUNET_array_grow (gossip_list, gossip_list_size, 0); | 1450 | GNUNET_array_grow (gossip_list, gossip_list_size, 0); |