diff options
Diffstat (limited to 'src/util/mq.c')
-rw-r--r-- | src/util/mq.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/util/mq.c b/src/util/mq.c index b22d97f59..e9dba3d9d 100644 --- a/src/util/mq.c +++ b/src/util/mq.c | |||
@@ -359,6 +359,7 @@ GNUNET_MQ_send (struct GNUNET_MQ_Handle *mq, | |||
359 | GNUNET_assert (NULL != mq); | 359 | GNUNET_assert (NULL != mq); |
360 | GNUNET_assert (NULL == ev->parent_queue); | 360 | GNUNET_assert (NULL == ev->parent_queue); |
361 | 361 | ||
362 | mq->queue_length++; | ||
362 | ev->parent_queue = mq; | 363 | ev->parent_queue = mq; |
363 | /* is the implementation busy? queue it! */ | 364 | /* is the implementation busy? queue it! */ |
364 | if (NULL != mq->current_envelope) | 365 | if (NULL != mq->current_envelope) |
@@ -366,11 +367,12 @@ GNUNET_MQ_send (struct GNUNET_MQ_Handle *mq, | |||
366 | GNUNET_CONTAINER_DLL_insert_tail (mq->envelope_head, | 367 | GNUNET_CONTAINER_DLL_insert_tail (mq->envelope_head, |
367 | mq->envelope_tail, | 368 | mq->envelope_tail, |
368 | ev); | 369 | ev); |
369 | mq->queue_length++; | ||
370 | return; | 370 | return; |
371 | } | 371 | } |
372 | mq->current_envelope = ev; | 372 | mq->current_envelope = ev; |
373 | mq->send_impl (mq, ev->mh, mq->impl_state); | 373 | mq->send_impl (mq, |
374 | ev->mh, | ||
375 | mq->impl_state); | ||
374 | } | 376 | } |
375 | 377 | ||
376 | 378 | ||
@@ -422,6 +424,8 @@ impl_send_continue (void *cls) | |||
422 | current_envelope = mq->current_envelope; | 424 | current_envelope = mq->current_envelope; |
423 | GNUNET_assert (NULL != current_envelope); | 425 | GNUNET_assert (NULL != current_envelope); |
424 | current_envelope->parent_queue = NULL; | 426 | current_envelope->parent_queue = NULL; |
427 | GNUNET_assert (0 < mq->queue_length); | ||
428 | mq->queue_length--; | ||
425 | if (NULL == mq->envelope_head) | 429 | if (NULL == mq->envelope_head) |
426 | { | 430 | { |
427 | mq->current_envelope = NULL; | 431 | mq->current_envelope = NULL; |
@@ -432,7 +436,6 @@ impl_send_continue (void *cls) | |||
432 | GNUNET_CONTAINER_DLL_remove (mq->envelope_head, | 436 | GNUNET_CONTAINER_DLL_remove (mq->envelope_head, |
433 | mq->envelope_tail, | 437 | mq->envelope_tail, |
434 | mq->current_envelope); | 438 | mq->current_envelope); |
435 | mq->queue_length--; | ||
436 | mq->send_impl (mq, | 439 | mq->send_impl (mq, |
437 | mq->current_envelope->mh, | 440 | mq->current_envelope->mh, |
438 | mq->impl_state); | 441 | mq->impl_state); |
@@ -973,7 +976,6 @@ GNUNET_MQ_destroy (struct GNUNET_MQ_Handle *mq) | |||
973 | mq->queue_length--; | 976 | mq->queue_length--; |
974 | GNUNET_MQ_discard (ev); | 977 | GNUNET_MQ_discard (ev); |
975 | } | 978 | } |
976 | GNUNET_assert (0 == mq->queue_length); | ||
977 | if (NULL != mq->current_envelope) | 979 | if (NULL != mq->current_envelope) |
978 | { | 980 | { |
979 | /* we can only discard envelopes that | 981 | /* we can only discard envelopes that |
@@ -981,7 +983,9 @@ GNUNET_MQ_destroy (struct GNUNET_MQ_Handle *mq) | |||
981 | mq->current_envelope->parent_queue = NULL; | 983 | mq->current_envelope->parent_queue = NULL; |
982 | GNUNET_MQ_discard (mq->current_envelope); | 984 | GNUNET_MQ_discard (mq->current_envelope); |
983 | mq->current_envelope = NULL; | 985 | mq->current_envelope = NULL; |
986 | mq->queue_length--; | ||
984 | } | 987 | } |
988 | GNUNET_assert (0 == mq->queue_length); | ||
985 | if (NULL != mq->assoc_map) | 989 | if (NULL != mq->assoc_map) |
986 | { | 990 | { |
987 | GNUNET_CONTAINER_multihashmap32_destroy (mq->assoc_map); | 991 | GNUNET_CONTAINER_multihashmap32_destroy (mq->assoc_map); |
@@ -1039,6 +1043,7 @@ GNUNET_MQ_send_cancel (struct GNUNET_MQ_Envelope *ev) | |||
1039 | { | 1043 | { |
1040 | // complex case, we already started with transmitting | 1044 | // complex case, we already started with transmitting |
1041 | // the message | 1045 | // the message |
1046 | mq->queue_length--; | ||
1042 | mq->cancel_impl (mq, | 1047 | mq->cancel_impl (mq, |
1043 | mq->impl_state); | 1048 | mq->impl_state); |
1044 | // continue sending the next message, if any | 1049 | // continue sending the next message, if any |