diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-11-16 17:41:13 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-11-16 17:41:13 +0000 |
commit | ba0bf2a585c2b59890d8f67074b74725430e86e8 (patch) | |
tree | d4f98f90560b63b632b686a5a6cb6a03c52c6d8a /src/util/mq.c | |
parent | e6fdcba7a3f54eefde196ccbc606acd62d30fb0f (diff) | |
download | gnunet-ba0bf2a585c2b59890d8f67074b74725430e86e8.tar.gz gnunet-ba0bf2a585c2b59890d8f67074b74725430e86e8.zip |
-remove GNUNET_MQ_impl_send_commit, make it part of send_continue, to ensure calling the continuation _last_
Diffstat (limited to 'src/util/mq.c')
-rw-r--r-- | src/util/mq.c | 59 |
1 files changed, 15 insertions, 44 deletions
diff --git a/src/util/mq.c b/src/util/mq.c index d8659ec40..3cf5da496 100644 --- a/src/util/mq.c +++ b/src/util/mq.c | |||
@@ -121,12 +121,6 @@ struct GNUNET_MQ_Handle | |||
121 | struct GNUNET_MQ_Envelope *current_envelope; | 121 | struct GNUNET_MQ_Envelope *current_envelope; |
122 | 122 | ||
123 | /** | 123 | /** |
124 | * Has the current envelope been commited? | ||
125 | * Either GNUNET_YES or GNUNET_NO. | ||
126 | */ | ||
127 | int commited; | ||
128 | |||
129 | /** | ||
130 | * Map of associations, lazily allocated | 124 | * Map of associations, lazily allocated |
131 | */ | 125 | */ |
132 | struct GNUNET_CONTAINER_MultiHashMap32 *assoc_map; | 126 | struct GNUNET_CONTAINER_MultiHashMap32 *assoc_map; |
@@ -265,25 +259,27 @@ GNUNET_MQ_send (struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev) | |||
265 | void | 259 | void |
266 | GNUNET_MQ_impl_send_continue (struct GNUNET_MQ_Handle *mq) | 260 | GNUNET_MQ_impl_send_continue (struct GNUNET_MQ_Handle *mq) |
267 | { | 261 | { |
262 | struct GNUNET_MQ_Envelope *current_envelope; | ||
263 | |||
268 | /* call is only valid if we're actually currently sending | 264 | /* call is only valid if we're actually currently sending |
269 | * a message */ | 265 | * a message */ |
270 | GNUNET_assert (NULL != mq); | 266 | current_envelope = mq->current_envelope; |
271 | GNUNET_assert (NULL != mq->current_envelope); | 267 | GNUNET_assert (NULL != current_envelope); |
272 | GNUNET_assert (GNUNET_YES == mq->commited); | ||
273 | mq->commited = GNUNET_NO; | ||
274 | GNUNET_free (mq->current_envelope); | ||
275 | if (NULL == mq->envelope_head) | 268 | if (NULL == mq->envelope_head) |
276 | { | 269 | { |
277 | mq->current_envelope = NULL; | 270 | mq->current_envelope = NULL; |
278 | return; | ||
279 | } | 271 | } |
280 | 272 | else | |
281 | GNUNET_assert (NULL != mq->envelope_tail); | 273 | { |
282 | GNUNET_assert (NULL != mq->envelope_head); | 274 | mq->current_envelope = mq->envelope_head; |
283 | mq->current_envelope = mq->envelope_head; | 275 | GNUNET_CONTAINER_DLL_remove (mq->envelope_head, |
284 | GNUNET_CONTAINER_DLL_remove (mq->envelope_head, mq->envelope_tail, | 276 | mq->envelope_tail, |
285 | mq->current_envelope); | 277 | mq->current_envelope); |
286 | mq->send_impl (mq, mq->current_envelope->mh, mq->impl_state); | 278 | mq->send_impl (mq, mq->current_envelope->mh, mq->impl_state); |
279 | } | ||
280 | if (NULL != current_envelope->sent_cb) | ||
281 | current_envelope->sent_cb (current_envelope->sent_cls); | ||
282 | GNUNET_free (current_envelope); | ||
287 | } | 283 | } |
288 | 284 | ||
289 | 285 | ||
@@ -362,25 +358,6 @@ GNUNET_MQ_impl_state (struct GNUNET_MQ_Handle *mq) | |||
362 | } | 358 | } |
363 | 359 | ||
364 | 360 | ||
365 | |||
366 | /** | ||
367 | * Mark the current message as irrevocably sent, but do not | ||
368 | * proceed with sending the next message. | ||
369 | * Will call the appropriate GNUNET_MQ_NotifyCallback, if any. | ||
370 | * | ||
371 | * @param mq message queue | ||
372 | */ | ||
373 | void | ||
374 | GNUNET_MQ_impl_send_commit (struct GNUNET_MQ_Handle *mq) | ||
375 | { | ||
376 | GNUNET_assert (NULL != mq->current_envelope); | ||
377 | GNUNET_assert (GNUNET_NO == mq->commited); | ||
378 | mq->commited = GNUNET_YES; | ||
379 | if (NULL != mq->current_envelope->sent_cb) | ||
380 | mq->current_envelope->sent_cb (mq->current_envelope->sent_cls); | ||
381 | } | ||
382 | |||
383 | |||
384 | struct GNUNET_MQ_Envelope * | 361 | struct GNUNET_MQ_Envelope * |
385 | GNUNET_MQ_msg_ (struct GNUNET_MessageHeader **mhp, uint16_t size, uint16_t type) | 362 | GNUNET_MQ_msg_ (struct GNUNET_MessageHeader **mhp, uint16_t size, uint16_t type) |
386 | { | 363 | { |
@@ -479,9 +456,6 @@ server_client_send_impl (struct GNUNET_MQ_Handle *mq, | |||
479 | 456 | ||
480 | GNUNET_assert (NULL != mq); | 457 | GNUNET_assert (NULL != mq); |
481 | GNUNET_assert (NULL != state); | 458 | GNUNET_assert (NULL != state); |
482 | |||
483 | GNUNET_MQ_impl_send_commit (mq); | ||
484 | |||
485 | state->th = | 459 | state->th = |
486 | GNUNET_SERVER_notify_transmit_ready (state->client, ntohs (msg->size), | 460 | GNUNET_SERVER_notify_transmit_ready (state->client, ntohs (msg->size), |
487 | GNUNET_TIME_UNIT_FOREVER_REL, | 461 | GNUNET_TIME_UNIT_FOREVER_REL, |
@@ -596,9 +570,6 @@ connection_client_send_impl (struct GNUNET_MQ_Handle *mq, | |||
596 | 570 | ||
597 | GNUNET_assert (NULL != state); | 571 | GNUNET_assert (NULL != state); |
598 | GNUNET_assert (NULL == state->th); | 572 | GNUNET_assert (NULL == state->th); |
599 | |||
600 | GNUNET_MQ_impl_send_commit (mq); | ||
601 | |||
602 | state->th = | 573 | state->th = |
603 | GNUNET_CLIENT_notify_transmit_ready (state->connection, ntohs (msg->size), | 574 | GNUNET_CLIENT_notify_transmit_ready (state->connection, ntohs (msg->size), |
604 | GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_NO, | 575 | GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_NO, |