diff options
author | Julius Bünger <buenger@mytum.de> | 2018-03-08 21:52:53 +0100 |
---|---|---|
committer | Julius Bünger <buenger@mytum.de> | 2018-03-08 21:54:02 +0100 |
commit | 5867b595b726c580f1fb50a4a83dd406561c2723 (patch) | |
tree | ef6c4792a6dce1ce702f4571217fb09552614323 /src/rps | |
parent | da76b1b40e8a4492dfdffe6cd6201c13db1b5a24 (diff) | |
download | gnunet-5867b595b726c580f1fb50a4a83dd406561c2723.tar.gz gnunet-5867b595b726c580f1fb50a4a83dd406561c2723.zip |
rps service: minor changes and logging
Diffstat (limited to 'src/rps')
-rw-r--r-- | src/rps/gnunet-service-rps.c | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c index c424ac37f..3fa7c1a18 100644 --- a/src/rps/gnunet-service-rps.c +++ b/src/rps/gnunet-service-rps.c | |||
@@ -648,8 +648,7 @@ get_mq (const struct GNUNET_PeerIdentity *peer) | |||
648 | 648 | ||
649 | if (NULL == peer_ctx->mq) | 649 | if (NULL == peer_ctx->mq) |
650 | { | 650 | { |
651 | (void) get_channel (peer); | 651 | peer_ctx->mq = GNUNET_CADET_get_mq (get_channel (peer)); |
652 | peer_ctx->mq = GNUNET_CADET_get_mq (peer_ctx->send_channel); | ||
653 | } | 652 | } |
654 | return peer_ctx->mq; | 653 | return peer_ctx->mq; |
655 | } | 654 | } |
@@ -1042,13 +1041,11 @@ restore_valid_peers () | |||
1042 | * | 1041 | * |
1043 | * @param fn_valid_peers filename of the file used to store valid peer ids | 1042 | * @param fn_valid_peers filename of the file used to store valid peer ids |
1044 | * @param cadet_h cadet handle | 1043 | * @param cadet_h cadet handle |
1045 | * @param disconnect_handler Disconnect handler | ||
1046 | * @param own_id own peer identity | 1044 | * @param own_id own peer identity |
1047 | */ | 1045 | */ |
1048 | void | 1046 | void |
1049 | Peers_initialise (char* fn_valid_peers, | 1047 | Peers_initialise (char* fn_valid_peers, |
1050 | struct GNUNET_CADET_Handle *cadet_h, | 1048 | struct GNUNET_CADET_Handle *cadet_h, |
1051 | GNUNET_CADET_DisconnectEventHandler disconnect_handler, | ||
1052 | const struct GNUNET_PeerIdentity *own_id) | 1049 | const struct GNUNET_PeerIdentity *own_id) |
1053 | { | 1050 | { |
1054 | filename_valid_peers = GNUNET_strdup (fn_valid_peers); | 1051 | filename_valid_peers = GNUNET_strdup (fn_valid_peers); |
@@ -1281,6 +1278,7 @@ Peers_remove_peer (const struct GNUNET_PeerIdentity *peer) | |||
1281 | "Destroying send channel\n"); | 1278 | "Destroying send channel\n"); |
1282 | GNUNET_CADET_channel_destroy (peer_ctx->send_channel); | 1279 | GNUNET_CADET_channel_destroy (peer_ctx->send_channel); |
1283 | peer_ctx->send_channel = NULL; | 1280 | peer_ctx->send_channel = NULL; |
1281 | peer_ctx->mq = NULL; | ||
1284 | } | 1282 | } |
1285 | channel_flag = Peers_get_channel_flag (peer, Peers_CHANNEL_ROLE_RECEIVING); | 1283 | channel_flag = Peers_get_channel_flag (peer, Peers_CHANNEL_ROLE_RECEIVING); |
1286 | if (NULL != peer_ctx->recv_channel && | 1284 | if (NULL != peer_ctx->recv_channel && |
@@ -1677,15 +1675,23 @@ Peers_cleanup_destroyed_channel (void *cls, | |||
1677 | /* FIXME This distinction seems to be redundant */ | 1675 | /* FIXME This distinction seems to be redundant */ |
1678 | if (Peers_check_peer_flag (peer, Peers_TO_DESTROY)) | 1676 | if (Peers_check_peer_flag (peer, Peers_TO_DESTROY)) |
1679 | {/* We initiatad the destruction of this particular peer */ | 1677 | {/* We initiatad the destruction of this particular peer */ |
1678 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1679 | "Peer is in the process of being destroyed\n"); | ||
1680 | if (channel == peer_ctx->send_channel) | 1680 | if (channel == peer_ctx->send_channel) |
1681 | { | ||
1681 | peer_ctx->send_channel = NULL; | 1682 | peer_ctx->send_channel = NULL; |
1683 | peer_ctx->mq = NULL; | ||
1684 | } | ||
1682 | else if (channel == peer_ctx->recv_channel) | 1685 | else if (channel == peer_ctx->recv_channel) |
1686 | { | ||
1683 | peer_ctx->recv_channel = NULL; | 1687 | peer_ctx->recv_channel = NULL; |
1688 | } | ||
1684 | 1689 | ||
1685 | if (NULL != peer_ctx->send_channel) | 1690 | if (NULL != peer_ctx->send_channel) |
1686 | { | 1691 | { |
1687 | GNUNET_CADET_channel_destroy (peer_ctx->send_channel); | 1692 | GNUNET_CADET_channel_destroy (peer_ctx->send_channel); |
1688 | peer_ctx->send_channel = NULL; | 1693 | peer_ctx->send_channel = NULL; |
1694 | peer_ctx->mq = NULL; | ||
1689 | } | 1695 | } |
1690 | if (NULL != peer_ctx->recv_channel) | 1696 | if (NULL != peer_ctx->recv_channel) |
1691 | { | 1697 | { |
@@ -1699,12 +1705,15 @@ Peers_cleanup_destroyed_channel (void *cls, | |||
1699 | 1705 | ||
1700 | else | 1706 | else |
1701 | { /* We did not initiate the destruction of this peer */ | 1707 | { /* We did not initiate the destruction of this peer */ |
1708 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1709 | "Peer is NOT in the process of being destroyed\n"); | ||
1702 | if (channel == peer_ctx->send_channel) | 1710 | if (channel == peer_ctx->send_channel) |
1703 | { /* Something (but us) killd the channel - clean up peer */ | 1711 | { /* Something (but us) killd the channel - clean up peer */ |
1704 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1712 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1705 | "send channel (%s) was destroyed - cleaning up\n", | 1713 | "send channel (%s) was destroyed - cleaning up\n", |
1706 | GNUNET_i2s (peer)); | 1714 | GNUNET_i2s (peer)); |
1707 | peer_ctx->send_channel = NULL; | 1715 | peer_ctx->send_channel = NULL; |
1716 | peer_ctx->mq = NULL; | ||
1708 | } | 1717 | } |
1709 | else if (channel == peer_ctx->recv_channel) | 1718 | else if (channel == peer_ctx->recv_channel) |
1710 | { /* Other peer doesn't want to send us messages anymore */ | 1719 | { /* Other peer doesn't want to send us messages anymore */ |
@@ -2617,10 +2626,19 @@ cleanup_destroyed_channel (void *cls, | |||
2617 | peer_ctx = get_peer_ctx (peer); | 2626 | peer_ctx = get_peer_ctx (peer); |
2618 | if (GNUNET_YES == Peers_check_channel_role (peer, channel, Peers_CHANNEL_ROLE_RECEIVING)) | 2627 | if (GNUNET_YES == Peers_check_channel_role (peer, channel, Peers_CHANNEL_ROLE_RECEIVING)) |
2619 | { | 2628 | { |
2629 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
2630 | "Callback on destruction of recv-channel was called (%s)\n", | ||
2631 | GNUNET_i2s (peer)); | ||
2620 | set_channel_flag (peer_ctx->recv_channel_flags, Peers_CHANNEL_DESTROING); | 2632 | set_channel_flag (peer_ctx->recv_channel_flags, Peers_CHANNEL_DESTROING); |
2621 | } else if (GNUNET_YES == Peers_check_channel_role (peer, channel, Peers_CHANNEL_ROLE_SENDING)) | 2633 | } else if (GNUNET_YES == Peers_check_channel_role (peer, channel, Peers_CHANNEL_ROLE_SENDING)) |
2622 | { | 2634 | { |
2635 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
2636 | "Callback on destruction of send-channel was called (%s)\n", | ||
2637 | GNUNET_i2s (peer)); | ||
2623 | set_channel_flag (peer_ctx->send_channel_flags, Peers_CHANNEL_DESTROING); | 2638 | set_channel_flag (peer_ctx->send_channel_flags, Peers_CHANNEL_DESTROING); |
2639 | } else { | ||
2640 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
2641 | "Channel to be destroyed has is neither sending nor receiving role\n"); | ||
2624 | } | 2642 | } |
2625 | 2643 | ||
2626 | if (GNUNET_YES == Peers_check_peer_flag (peer, Peers_TO_DESTROY)) | 2644 | if (GNUNET_YES == Peers_check_peer_flag (peer, Peers_TO_DESTROY)) |
@@ -3080,7 +3098,10 @@ handle_peer_check (void *cls, | |||
3080 | const struct GNUNET_MessageHeader *msg) | 3098 | const struct GNUNET_MessageHeader *msg) |
3081 | { | 3099 | { |
3082 | const struct GNUNET_PeerIdentity *peer = cls; | 3100 | const struct GNUNET_PeerIdentity *peer = cls; |
3101 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
3102 | "Received CHECK_LIVE (%s)\n", GNUNET_i2s (peer)); | ||
3083 | 3103 | ||
3104 | GNUNET_break_op (Peers_check_peer_known (peer)); | ||
3084 | GNUNET_CADET_receive_done (Peers_get_recv_channel (peer)); | 3105 | GNUNET_CADET_receive_done (Peers_get_recv_channel (peer)); |
3085 | } | 3106 | } |
3086 | 3107 | ||
@@ -3137,6 +3158,7 @@ handle_peer_push (void *cls, | |||
3137 | /* Add the sending peer to the push_map */ | 3158 | /* Add the sending peer to the push_map */ |
3138 | CustomPeerMap_put (push_map, peer); | 3159 | CustomPeerMap_put (push_map, peer); |
3139 | 3160 | ||
3161 | GNUNET_break_op (Peers_check_peer_known (peer)); | ||
3140 | GNUNET_CADET_receive_done (Peers_get_recv_channel (peer)); | 3162 | GNUNET_CADET_receive_done (Peers_get_recv_channel (peer)); |
3141 | } | 3163 | } |
3142 | 3164 | ||
@@ -3307,6 +3329,7 @@ handle_peer_pull_reply (void *cls, | |||
3307 | Peers_unset_peer_flag (sender, Peers_PULL_REPLY_PENDING); | 3329 | Peers_unset_peer_flag (sender, Peers_PULL_REPLY_PENDING); |
3308 | clean_peer (sender); | 3330 | clean_peer (sender); |
3309 | 3331 | ||
3332 | GNUNET_break_op (Peers_check_peer_known (sender)); | ||
3310 | GNUNET_CADET_receive_done (Peers_get_recv_channel (sender)); | 3333 | GNUNET_CADET_receive_done (Peers_get_recv_channel (sender)); |
3311 | } | 3334 | } |
3312 | 3335 | ||
@@ -4274,8 +4297,7 @@ run (void *cls, | |||
4274 | 4297 | ||
4275 | 4298 | ||
4276 | peerinfo_handle = GNUNET_PEERINFO_connect (cfg); | 4299 | peerinfo_handle = GNUNET_PEERINFO_connect (cfg); |
4277 | Peers_initialise (fn_valid_peers, cadet_handle, cleanup_destroyed_channel, | 4300 | Peers_initialise (fn_valid_peers, cadet_handle, &own_identity); |
4278 | &own_identity); | ||
4279 | GNUNET_free (fn_valid_peers); | 4301 | GNUNET_free (fn_valid_peers); |
4280 | 4302 | ||
4281 | /* Initialise sampler */ | 4303 | /* Initialise sampler */ |