aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2015-05-19 22:41:25 +0000
committerJulius Bünger <buenger@mytum.de>2015-05-19 22:41:25 +0000
commit19c09bcf839bb7db62dcf9de794d9e313d4bfd0e (patch)
tree765f0c5c13b54b87b90139650e72375e7442058c /src
parent8d1c8560be5f3fcd3fedbfb398f273a71890e22b (diff)
downloadgnunet-19c09bcf839bb7db62dcf9de794d9e313d4bfd0e.tar.gz
gnunet-19c09bcf839bb7db62dcf9de794d9e313d4bfd0e.zip
-tried to fix removal of peers
Diffstat (limited to 'src')
-rw-r--r--src/rps/gnunet-service-rps.c95
1 files changed, 55 insertions, 40 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index eb0fb3d82..45f20eb2e 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -2196,47 +2196,57 @@ peer_remove_cb (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
2196 struct GNUNET_CADET_Channel *recv; 2196 struct GNUNET_CADET_Channel *recv;
2197 struct GNUNET_CADET_Channel *send; 2197 struct GNUNET_CADET_Channel *send;
2198 2198
2199 if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (peer_map, value)) 2199 peer_ctx = (struct PeerContext *) value;
2200 {
2201 peer_ctx = (struct PeerContext *) value;
2202 2200
2203 if (0 != peer_ctx->num_outstanding_ops) 2201 LOG (GNUNET_ERROR_TYPE_DEBUG,
2204 GNUNET_array_grow (peer_ctx->outstanding_ops, 2202 "Going to clean peer %s\n",
2205 peer_ctx->num_outstanding_ops, 2203 GNUNET_i2s (&peer_ctx->peer_id));
2206 0);
2207 2204
2208 if (NULL != peer_ctx->mq) 2205 /* If operations are still scheduled for this peer cancel those */
2209 { 2206 if (0 != peer_ctx->num_outstanding_ops)
2210 GNUNET_MQ_destroy (peer_ctx->mq); 2207 GNUNET_array_grow (peer_ctx->outstanding_ops,
2211 peer_ctx->mq = NULL; 2208 peer_ctx->num_outstanding_ops,
2212 } 2209 0);
2213 2210
2211 /* If we are still waiting for notification whether this peer is live
2212 * cancel the according task */
2213 if (NULL != peer_ctx->is_live_task)
2214 {
2215 LOG (GNUNET_ERROR_TYPE_DEBUG,
2216 "Trying to cancle is_live_task for peer %s\n",
2217 GNUNET_i2s (key));
2218 GNUNET_CADET_notify_transmit_ready_cancel (peer_ctx->is_live_task);
2219 peer_ctx->is_live_task = NULL;
2220 }
2214 2221
2215 if (NULL != peer_ctx->is_live_task)
2216 {
2217 LOG (GNUNET_ERROR_TYPE_DEBUG,
2218 "Trying to cancle is_live_task for peer %s\n",
2219 GNUNET_i2s (key));
2220 GNUNET_CADET_notify_transmit_ready_cancel (peer_ctx->is_live_task);
2221 peer_ctx->is_live_task = NULL;
2222 }
2223 2222
2224 send = peer_ctx->send_channel; 2223 recv = peer_ctx->recv_channel;
2225 peer_ctx->send_channel = NULL; 2224 peer_ctx->recv_channel = NULL;
2226 if (NULL != send 2225 if (NULL != recv
2227 && channel != send) 2226 && channel != recv)
2228 { 2227 {
2229 GNUNET_CADET_channel_destroy (send); 2228 GNUNET_CADET_channel_destroy (recv);
2230 } 2229 }
2231 2230
2232 recv = peer_ctx->send_channel; 2231 /* If there is still a mq destroy it */
2233 peer_ctx->recv_channel = NULL; 2232 if (NULL != peer_ctx->mq)
2234 if (NULL != recv 2233 {
2235 && channel != recv) 2234 GNUNET_MQ_destroy (peer_ctx->mq);
2236 { 2235 peer_ctx->mq = NULL;
2237 GNUNET_CADET_channel_destroy (recv); 2236 }
2238 }
2239 2237
2238 /* Remove the send_channel
2239 * The peer map entry should be removed
2240 * from the callback #cleanup_channel */
2241 send = peer_ctx->send_channel;
2242 peer_ctx->send_channel = NULL;
2243 if (NULL != send
2244 && channel != send)
2245 {
2246 GNUNET_CADET_channel_destroy (send);
2247 }
2248 else
2249 { /* If there is no channel we have to remove it now */
2240 if (GNUNET_YES != GNUNET_CONTAINER_multipeermap_remove_all (peer_map, key)) 2250 if (GNUNET_YES != GNUNET_CONTAINER_multipeermap_remove_all (peer_map, key))
2241 LOG (GNUNET_ERROR_TYPE_WARNING, "removing peer from peer_map failed\n"); 2251 LOG (GNUNET_ERROR_TYPE_WARNING, "removing peer from peer_map failed\n");
2242 else 2252 else
@@ -2275,7 +2285,6 @@ shutdown_task (void *cls,
2275 } 2285 }
2276 2286
2277 GNUNET_NSE_disconnect (nse); 2287 GNUNET_NSE_disconnect (nse);
2278 GNUNET_CADET_disconnect (cadet_handle);
2279 RPS_sampler_destroy (prot_sampler); 2288 RPS_sampler_destroy (prot_sampler);
2280 RPS_sampler_destroy (client_sampler); 2289 RPS_sampler_destroy (client_sampler);
2281 LOG (GNUNET_ERROR_TYPE_DEBUG, 2290 LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -2283,6 +2292,7 @@ shutdown_task (void *cls,
2283 GNUNET_CONTAINER_multipeermap_size (peer_map)); 2292 GNUNET_CONTAINER_multipeermap_size (peer_map));
2284 GNUNET_break (0 == GNUNET_CONTAINER_multipeermap_size (peer_map)); 2293 GNUNET_break (0 == GNUNET_CONTAINER_multipeermap_size (peer_map));
2285 GNUNET_CONTAINER_multipeermap_destroy (peer_map); 2294 GNUNET_CONTAINER_multipeermap_destroy (peer_map);
2295 GNUNET_CADET_disconnect (cadet_handle);
2286 GNUNET_array_grow (gossip_list, gossip_list_size, 0); 2296 GNUNET_array_grow (gossip_list, gossip_list_size, 0);
2287 GNUNET_array_grow (push_list, push_list_size, 0); 2297 GNUNET_array_grow (push_list, push_list_size, 0);
2288 GNUNET_array_grow (pull_list, pull_list_size, 0); 2298 GNUNET_array_grow (pull_list, pull_list_size, 0);
@@ -2381,17 +2391,17 @@ cleanup_channel (void *cls,
2381 // Guess simply casting isn't the nicest way... 2391 // Guess simply casting isn't the nicest way...
2382 // FIXME wait for cadet to change this function 2392 // FIXME wait for cadet to change this function
2383 2393
2384 if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (peer_map, peer)) 2394 //if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (peer_map, peer))
2385 { 2395 //{
2386 peer_ctx = GNUNET_CONTAINER_multipeermap_get (peer_map, peer); 2396 peer_ctx = GNUNET_CONTAINER_multipeermap_get (peer_map, peer);
2387 2397
2388 if (NULL == peer_ctx) /* It could have been removed by shutdown_task */ 2398 if (NULL == peer_ctx) /* It could have been removed by shutdown_task */
2389 return; 2399 return;
2390 2400
2391 if (channel == peer_ctx->send_channel) 2401 if (channel == peer_ctx->send_channel)
2392 { /* Peer probably went down */ 2402 { /* Peer went down or we killd the channel */
2393 LOG (GNUNET_ERROR_TYPE_DEBUG, 2403 LOG (GNUNET_ERROR_TYPE_DEBUG,
2394 "Peer %s destroyed send channel - probably went down, cleaning up\n", 2404 "send channel (%s) was destroyed - cleaning up\n",
2395 GNUNET_i2s (peer)); 2405 GNUNET_i2s (peer));
2396 rem_from_list (&gossip_list, &gossip_list_size, peer); 2406 rem_from_list (&gossip_list, &gossip_list_size, peer);
2397 rem_from_list (&pending_pull_reply_list, &pending_pull_reply_list_size, peer); 2407 rem_from_list (&pending_pull_reply_list, &pending_pull_reply_list_size, peer);
@@ -2400,6 +2410,11 @@ cleanup_channel (void *cls,
2400 /* Somwewhat {ab,re}use the iterator function */ 2410 /* Somwewhat {ab,re}use the iterator function */
2401 /* Cast to void is ok, because it's used as void in peer_remove_cb */ 2411 /* Cast to void is ok, because it's used as void in peer_remove_cb */
2402 (void) peer_remove_cb ((void *) channel, peer, peer_ctx); 2412 (void) peer_remove_cb ((void *) channel, peer, peer_ctx);
2413
2414 //if (GNUNET_YES != GNUNET_CONTAINER_multipeermap_remove_all (peer_map, key))
2415 // LOG (GNUNET_ERROR_TYPE_WARNING, "Removing peer from peer_map failed\n");
2416 //else
2417 // GNUNET_free (peer_ctx);
2403 } 2418 }
2404 else if (channel == peer_ctx->recv_channel) 2419 else if (channel == peer_ctx->recv_channel)
2405 { /* Other peer doesn't want to send us messages anymore */ 2420 { /* Other peer doesn't want to send us messages anymore */
@@ -2408,7 +2423,7 @@ cleanup_channel (void *cls,
2408 GNUNET_i2s (peer)); 2423 GNUNET_i2s (peer));
2409 peer_ctx->recv_channel = NULL; 2424 peer_ctx->recv_channel = NULL;
2410 } 2425 }
2411 } 2426 //}
2412} 2427}
2413 2428
2414 2429