aboutsummaryrefslogtreecommitdiff
path: root/src/mesh
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2012-09-29 00:24:01 +0000
committerBart Polot <bart@net.in.tum.de>2012-09-29 00:24:01 +0000
commitd0113d38c7859a84adc8041671f828903db58d2c (patch)
treeb8e0daf4990542946985ff19dcbdab2ea5118be1 /src/mesh
parent1ca51e5871f9b471425f9c88c358cb963a68aaed (diff)
downloadgnunet-d0113d38c7859a84adc8041671f828903db58d2c.tar.gz
gnunet-d0113d38c7859a84adc8041671f828903db58d2c.zip
- dont crash on cleanup
Diffstat (limited to 'src/mesh')
-rw-r--r--src/mesh/gnunet-service-mesh.c44
1 files changed, 25 insertions, 19 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index 6d0648d28..ac519d20d 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -3497,6 +3497,10 @@ tunnel_get_neighbor_fc (const struct MeshTunnel *t,
3497 const struct GNUNET_PeerIdentity *peer) 3497 const struct GNUNET_PeerIdentity *peer)
3498{ 3498{
3499 struct MeshTunnelChildInfo *cinfo; 3499 struct MeshTunnelChildInfo *cinfo;
3500
3501 if (NULL == t->children_fc)
3502 return NULL;
3503
3500 cinfo = GNUNET_CONTAINER_multihashmap_get (t->children_fc, 3504 cinfo = GNUNET_CONTAINER_multihashmap_get (t->children_fc,
3501 &peer->hashPubKey); 3505 &peer->hashPubKey);
3502 if (NULL == cinfo) 3506 if (NULL == cinfo)
@@ -4243,9 +4247,9 @@ tunnel_destroy (struct MeshTunnel *t)
4243 &tunnel_destroy_child, 4247 &tunnel_destroy_child,
4244 t); 4248 t);
4245 GNUNET_CONTAINER_multihashmap_destroy (t->children_fc); 4249 GNUNET_CONTAINER_multihashmap_destroy (t->children_fc);
4250 t->children_fc = NULL;
4246 4251
4247 tree_iterate_children (t->tree, &tunnel_cancel_queues, t); 4252 tree_iterate_children (t->tree, &tunnel_cancel_queues, t);
4248
4249 tree_destroy (t->tree); 4253 tree_destroy (t->tree);
4250 4254
4251 if (NULL != t->regex_ctx) 4255 if (NULL != t->regex_ctx)
@@ -4635,30 +4639,31 @@ queue_destroy (struct MeshPeerQueue *queue, int clear_cls)
4635 max = queue->tunnel->fwd_queue_max; 4639 max = queue->tunnel->fwd_queue_max;
4636 GNUNET_PEER_resolve (queue->peer->id, &id); 4640 GNUNET_PEER_resolve (queue->peer->id, &id);
4637 cinfo = tunnel_get_neighbor_fc (queue->tunnel, &id); 4641 cinfo = tunnel_get_neighbor_fc (queue->tunnel, &id);
4638 for (i = 0; i < cinfo->send_buffer_n; i++) 4642 if (NULL != cinfo)
4639 { 4643 {
4640 unsigned int i2; 4644 for (i = 0; i < cinfo->send_buffer_n; i++)
4641 i2 = (cinfo->send_buffer_start + i) % max;
4642 if (cinfo->send_buffer[i2] == queue)
4643 { 4645 {
4644 /* Found corresponding entry in the send_buffer. Move all others back. */ 4646 unsigned int i2;
4645 unsigned int j; 4647 i2 = (cinfo->send_buffer_start + i) % max;
4646 unsigned int j2; 4648 if (cinfo->send_buffer[i2] == queue)
4647 unsigned int j3;
4648
4649 for (j = i, j2 = 0, j3 = 0; j < cinfo->send_buffer_n - 1; j++)
4650 { 4649 {
4651 j2 = (cinfo->send_buffer_start + j) % max; 4650 /* Found corresponding entry in the send_buffer. Move all others back. */
4652 j3 = (cinfo->send_buffer_start + j + 1) % max; 4651 unsigned int j;
4653 cinfo->send_buffer[j2] = cinfo->send_buffer[j3]; 4652 unsigned int j2;
4654 } 4653 unsigned int j3;
4655 4654
4656 cinfo->send_buffer[j3] = NULL; 4655 for (j = i, j2 = 0, j3 = 0; j < cinfo->send_buffer_n - 1; j++)
4656 {
4657 j2 = (cinfo->send_buffer_start + j) % max;
4658 j3 = (cinfo->send_buffer_start + j + 1) % max;
4659 cinfo->send_buffer[j2] = cinfo->send_buffer[j3];
4660 }
4657 4661
4658 cinfo->send_buffer_n--; 4662 cinfo->send_buffer[j3] = NULL;
4663 cinfo->send_buffer_n--;
4664 }
4659 } 4665 }
4660 } 4666 }
4661 //queue->
4662 4667
4663 GNUNET_free (queue); 4668 GNUNET_free (queue);
4664} 4669}
@@ -4917,8 +4922,9 @@ queue_send (void *cls, size_t size, void *buf)
4917 /* Free queue, but cls was freed by send_core_* */ 4922 /* Free queue, but cls was freed by send_core_* */
4918 queue_destroy (queue, GNUNET_NO); 4923 queue_destroy (queue, GNUNET_NO);
4919 4924
4920 if (GNUNET_YES == t->destroy && 0 == t->fwd_queue_n) 4925 if (GNUNET_YES == t->destroy)
4921 { 4926 {
4927 // FIXME fc tunnel destroy all pending traffic? wait for it?
4922 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* destroying tunnel!\n"); 4928 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* destroying tunnel!\n");
4923 tunnel_destroy (t); 4929 tunnel_destroy (t);
4924 } 4930 }