diff options
author | bartpolot <bartpolot@140774ce-b5e7-0310-ab8b-a85725594a96> | 2013-10-21 15:59:44 +0000 |
---|---|---|
committer | bartpolot <bartpolot@140774ce-b5e7-0310-ab8b-a85725594a96> | 2013-10-21 15:59:44 +0000 |
commit | 6eb4c5e5d56ea4eea93d5d0666f93f39d21d4bf6 (patch) | |
tree | 6aedbe02e3e14825c681b16bdb9788647baa28e2 /src | |
parent | 891be7ff912e663498733bc0a68719f3dcdfbc43 (diff) |
- fix reentrant looping
git-svn-id: https://gnunet.org/svn/gnunet@30379 140774ce-b5e7-0310-ab8b-a85725594a96
Diffstat (limited to 'src')
-rw-r--r-- | src/mesh/gnunet-service-mesh_peer.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/mesh/gnunet-service-mesh_peer.c b/src/mesh/gnunet-service-mesh_peer.c index b6a241b24e..8631aea6fd 100644 --- a/src/mesh/gnunet-service-mesh_peer.c +++ b/src/mesh/gnunet-service-mesh_peer.c @@ -1073,16 +1073,29 @@ GMP_queue_cancel (struct MeshPeer *peer, struct MeshConnection *c) { struct MeshPeerQueue *q; struct MeshPeerQueue *next; + struct MeshPeerQueue *prev; for (q = peer->queue_head; NULL != q; q = next) { - next = q->next; + prev = q->prev; if (q->c == c) { LOG (GNUNET_ERROR_TYPE_DEBUG, - "connection_cancel_queue %s\n", + "GMP_cancel_queue %s\n", GNUNET_MESH_DEBUG_M2S (q->type)); queue_destroy (q, GNUNET_YES); + + /* Get next from prev, q->next might be already freed: + * queue destroy -> callback -> GMC_destroy -> cancel_queues -> here + */ + if (NULL == prev) + next = peer->queue_head; + else + next = prev->next; + } + else + { + next = q->next; } } if (NULL == peer->queue_head) |