aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2015-01-18 15:55:20 +0000
committerJulius Bünger <buenger@mytum.de>2015-01-18 15:55:20 +0000
commitc5f60b28bfafd0b8196eb110e7cb3a8a1b12aa0f (patch)
treec5b3046a5546bdd06667213cd6bf8a6b2c827ec6
parent4ec3377776569a7affcaf6b69db9312ad1891ba5 (diff)
downloadgnunet-c5f60b28bfafd0b8196eb110e7cb3a8a1b12aa0f.tar.gz
gnunet-c5f60b28bfafd0b8196eb110e7cb3a8a1b12aa0f.zip
simplified removal of peers from peermap
-rw-r--r--src/rps/gnunet-service-rps.c24
1 files changed, 4 insertions, 20 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index cbcacb2db..86b5d7443 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -1056,22 +1056,8 @@ init_peer_cb (void *cls,
1056 int 1056 int
1057peer_remove_cb (void *cls, const struct GNUNET_PeerIdentity *key, void *value) 1057peer_remove_cb (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
1058{ 1058{
1059 struct GNUNET_PeerIdentity *tmp_id;
1060 struct PeerContext *peer_ctx; 1059 struct PeerContext *peer_ctx;
1061 1060
1062 /* Check if we are starting to again iterate over same peers */
1063 if (NULL == cls)
1064 { /* Store first id we see */
1065 tmp_id = GNUNET_new (struct GNUNET_PeerIdentity);
1066 *tmp_id = *key;
1067 cls = tmp_id;
1068 }
1069 else if (0 == GNUNET_CRYPTO_cmp_peer_identity (key, cls))
1070 { /* Check if we see the first id again */
1071 GNUNET_free (cls);
1072 return GNUNET_NO;
1073 }
1074
1075 peer_ctx = (struct PeerContext *) value; 1061 peer_ctx = (struct PeerContext *) value;
1076 1062
1077 if ( NULL != peer_ctx->mq) 1063 if ( NULL != peer_ctx->mq)
@@ -1083,7 +1069,8 @@ peer_remove_cb (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
1083 if ( NULL != peer_ctx->from_channel) 1069 if ( NULL != peer_ctx->from_channel)
1084 GNUNET_CADET_channel_destroy (peer_ctx->from_channel); 1070 GNUNET_CADET_channel_destroy (peer_ctx->from_channel);
1085 1071
1086 // call _peermap_remove_all()? 1072 if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_remove_all (peer_map, key))
1073 LOG (GNUNET_ERROR_TYPE_WARNING, "removing peer from peer_map failed\n");
1087 1074
1088 return GNUNET_YES; 1075 return GNUNET_YES;
1089} 1076}
@@ -1101,16 +1088,14 @@ shutdown_task (void *cls,
1101{ 1088{
1102 LOG (GNUNET_ERROR_TYPE_DEBUG, "RPS is going down\n"); 1089 LOG (GNUNET_ERROR_TYPE_DEBUG, "RPS is going down\n");
1103 1090
1104 uint32_t num_peers;
1105
1106 if ( NULL != do_round_task ) 1091 if ( NULL != do_round_task )
1107 { 1092 {
1108 GNUNET_SCHEDULER_cancel (do_round_task); 1093 GNUNET_SCHEDULER_cancel (do_round_task);
1109 do_round_task = NULL; 1094 do_round_task = NULL;
1110 } 1095 }
1111 1096
1112 num_peers = GNUNET_CONTAINER_multipeermap_iterate (peer_map, peer_remove_cb, NULL); 1097
1113 if (GNUNET_SYSERR == num_peers) 1098 if (GNUNET_SYSERR == GNUNET_CONTAINER_multipeermap_iterate (peer_map, peer_remove_cb, NULL))
1114 LOG (GNUNET_ERROR_TYPE_WARNING, 1099 LOG (GNUNET_ERROR_TYPE_WARNING,
1115 "Iterating over peers to disconnect from them was cancelled\n"); 1100 "Iterating over peers to disconnect from them was cancelled\n");
1116 1101
@@ -1205,7 +1190,6 @@ cleanup_channel (void *cls,
1205 peer_ctx = GNUNET_CONTAINER_multipeermap_get (peer_map, peer); 1190 peer_ctx = GNUNET_CONTAINER_multipeermap_get (peer_map, peer);
1206 /* Somwewhat {ab,re}use the iterator function */ 1191 /* Somwewhat {ab,re}use the iterator function */
1207 (void) peer_remove_cb (peer, peer, peer_ctx); 1192 (void) peer_remove_cb (peer, peer, peer_ctx);
1208 GNUNET_CONTAINER_multipeermap_remove_all (peer_map, peer);
1209} 1193}
1210 1194
1211/** 1195/**