diff options
author | Julius Bünger <buenger@mytum.de> | 2015-01-17 22:08:08 +0000 |
---|---|---|
committer | Julius Bünger <buenger@mytum.de> | 2015-01-17 22:08:08 +0000 |
commit | 4756cb0779daf3e4c33b6e876dce956de7ee6dd8 (patch) | |
tree | fe80e728f7d8521bbec1285d1d6e8f51782e7426 /src | |
parent | 817e9efeb43fad3d3abae6d75355b0b88da35a32 (diff) | |
download | gnunet-4756cb0779daf3e4c33b6e876dce956de7ee6dd8.tar.gz gnunet-4756cb0779daf3e4c33b6e876dce956de7ee6dd8.zip |
cleaning up disconnected peers
Diffstat (limited to 'src')
-rw-r--r-- | src/rps/gnunet-service-rps.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c index 9b37ccfe9..1e9ea0076 100644 --- a/src/rps/gnunet-service-rps.c +++ b/src/rps/gnunet-service-rps.c | |||
@@ -808,8 +808,6 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
808 | uint64_t i; | 808 | uint64_t i; |
809 | //unsigned int *n_arr; | 809 | //unsigned int *n_arr; |
810 | unsigned int n_peers; /* Number of peers we send pushes/pulls to */ | 810 | unsigned int n_peers; /* Number of peers we send pushes/pulls to */ |
811 | struct GNUNET_MessageHeader *push_msg; | ||
812 | struct GNUNET_MessageHeader *pull_msg; | ||
813 | struct GNUNET_MQ_Envelope *ev; | 811 | struct GNUNET_MQ_Envelope *ev; |
814 | const struct GNUNET_PeerIdentity *peer; | 812 | const struct GNUNET_PeerIdentity *peer; |
815 | struct GNUNET_MQ_Handle *mq; | 813 | struct GNUNET_MQ_Handle *mq; |
@@ -836,8 +834,7 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
836 | { // FIXME if this fails schedule/loop this for later | 834 | { // FIXME if this fails schedule/loop this for later |
837 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending PUSH to peer %s of gossiped list.\n", GNUNET_i2s (peer)); | 835 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending PUSH to peer %s of gossiped list.\n", GNUNET_i2s (peer)); |
838 | 836 | ||
839 | ev = GNUNET_MQ_msg (push_msg, GNUNET_MESSAGE_TYPE_RPS_PP_PUSH); | 837 | ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_RPS_PP_PUSH); |
840 | // TODO replace with GNUNET_MQ_msg_header | ||
841 | // FIXME sometimes it returns a pointer to a freed mq | 838 | // FIXME sometimes it returns a pointer to a freed mq |
842 | mq = get_mq (peer_map, peer); | 839 | mq = get_mq (peer_map, peer); |
843 | GNUNET_MQ_send (mq, ev); | 840 | GNUNET_MQ_send (mq, ev); |
@@ -859,8 +856,7 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
859 | { // FIXME if this fails schedule/loop this for later | 856 | { // FIXME if this fails schedule/loop this for later |
860 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending PULL request to peer %s of gossiped list.\n", GNUNET_i2s (peer)); | 857 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending PULL request to peer %s of gossiped list.\n", GNUNET_i2s (peer)); |
861 | 858 | ||
862 | ev = GNUNET_MQ_msg (pull_msg, GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REQUEST); | 859 | ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REQUEST); |
863 | // TODO replace with GNUNET_MQ_msg_header | ||
864 | //pull_msg = NULL; | 860 | //pull_msg = NULL; |
865 | mq = get_mq (peer_map, peer); | 861 | mq = get_mq (peer_map, peer); |
866 | GNUNET_MQ_send (mq, ev); | 862 | GNUNET_MQ_send (mq, ev); |
@@ -1059,8 +1055,22 @@ init_peer_cb (void *cls, | |||
1059 | int | 1055 | int |
1060 | peer_remove_cb (void *cls, const struct GNUNET_PeerIdentity *key, void *value) | 1056 | peer_remove_cb (void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
1061 | { | 1057 | { |
1058 | struct GNUNET_PeerIdentity *tmp_id; | ||
1062 | struct PeerContext *peer_ctx; | 1059 | struct PeerContext *peer_ctx; |
1063 | 1060 | ||
1061 | /* Check if we are starting to again iterate over same peers */ | ||
1062 | if (NULL == cls) | ||
1063 | { /* Store first id we see */ | ||
1064 | tmp_id = GNUNET_new (struct GNUNET_PeerIdentity); | ||
1065 | *tmp_id = *key; | ||
1066 | cls = tmp_id; | ||
1067 | } | ||
1068 | else if (0 == GNUNET_CRYPTO_cmp_peer_identity (key, cls)) | ||
1069 | { /* Check if we see the first id again */ | ||
1070 | GNUNET_free (cls); | ||
1071 | return GNUNET_NO; | ||
1072 | } | ||
1073 | |||
1064 | peer_ctx = (struct PeerContext *) value; | 1074 | peer_ctx = (struct PeerContext *) value; |
1065 | 1075 | ||
1066 | if ( NULL != peer_ctx->mq) | 1076 | if ( NULL != peer_ctx->mq) |
@@ -1179,6 +1189,8 @@ cleanup_channel (void *cls, | |||
1179 | void *channel_ctx) | 1189 | void *channel_ctx) |
1180 | { | 1190 | { |
1181 | struct GNUNET_PeerIdentity *peer; | 1191 | struct GNUNET_PeerIdentity *peer; |
1192 | struct PeerContext *peer_ctx; | ||
1193 | |||
1182 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Channel to remote peer was destroyed.\n"); | 1194 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Channel to remote peer was destroyed.\n"); |
1183 | 1195 | ||
1184 | peer = (struct GNUNET_PeerIdentity *) GNUNET_CADET_channel_get_info ( | 1196 | peer = (struct GNUNET_PeerIdentity *) GNUNET_CADET_channel_get_info ( |
@@ -1186,6 +1198,11 @@ cleanup_channel (void *cls, | |||
1186 | // Guess simply casting isn't the nicest way... | 1198 | // Guess simply casting isn't the nicest way... |
1187 | // FIXME wait for cadet to change this function | 1199 | // FIXME wait for cadet to change this function |
1188 | RPS_sampler_reinitialise_by_value (peer); | 1200 | RPS_sampler_reinitialise_by_value (peer); |
1201 | |||
1202 | peer_ctx = GNUNET_CONTAINER_multipeermap_get (peer_map, peer); | ||
1203 | /* Somwewhat {ab,re}use the iterator function */ | ||
1204 | (void) peer_remove_cb (peer, peer, peer_ctx); | ||
1205 | GNUNET_CONTAINER_multipeermap_remove_all (peer_map, peer); | ||
1189 | } | 1206 | } |
1190 | 1207 | ||
1191 | /** | 1208 | /** |