aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/conversation/conversation_api.c2
-rw-r--r--src/util/mq.c55
2 files changed, 43 insertions, 14 deletions
diff --git a/src/conversation/conversation_api.c b/src/conversation/conversation_api.c
index c8289fe01..d30846d22 100644
--- a/src/conversation/conversation_api.c
+++ b/src/conversation/conversation_api.c
@@ -261,7 +261,7 @@ handle_caller_name (void *cls,
261 if (NULL == label) 261 if (NULL == label)
262 name = GNUNET_strdup (GNUNET_GNSRECORD_pkey_to_zkey (&caller->caller_id)); 262 name = GNUNET_strdup (GNUNET_GNSRECORD_pkey_to_zkey (&caller->caller_id));
263 else 263 else
264 GNUNET_asprintf (&name, "%.gnu", label); 264 GNUNET_asprintf (&name, "%s.gnu", label);
265 caller->caller_id_str = name; 265 caller->caller_id_str = name;
266 caller->state = CS_RINGING; 266 caller->state = CS_RINGING;
267 phone->event_handler (phone->event_handler_cls, 267 phone->event_handler (phone->event_handler_cls,
diff --git a/src/util/mq.c b/src/util/mq.c
index 3cf5da496..bc13bbb36 100644
--- a/src/util/mq.c
+++ b/src/util/mq.c
@@ -126,6 +126,11 @@ struct GNUNET_MQ_Handle
126 struct GNUNET_CONTAINER_MultiHashMap32 *assoc_map; 126 struct GNUNET_CONTAINER_MultiHashMap32 *assoc_map;
127 127
128 /** 128 /**
129 * Task scheduled during #GNUNET_MQ_impl_send_continue.
130 */
131 GNUNET_SCHEDULER_TaskIdentifier continue_task;
132
133 /**
129 * Next id that should be used for the assoc_map, 134 * Next id that should be used for the assoc_map,
130 * initialized lazily to a random value together with 135 * initialized lazily to a random value together with
131 * assoc_map 136 * assoc_map
@@ -249,18 +254,21 @@ GNUNET_MQ_send (struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
249 254
250 255
251/** 256/**
252 * Call the send implementation for the next queued message, 257 * Task run to call the send implementation for the next queued
253 * if any. 258 * message, if any. Only useful for implementing message queues,
254 * Only useful for implementing message queues,
255 * results in undefined behavior if not used carefully. 259 * results in undefined behavior if not used carefully.
256 * 260 *
257 * @param mq message queue to send the next message with 261 * @param cls message queue to send the next message with
262 * @param tc scheduler context
258 */ 263 */
259void 264static void
260GNUNET_MQ_impl_send_continue (struct GNUNET_MQ_Handle *mq) 265impl_send_continue (void *cls,
266 const struct GNUNET_SCHEDULER_TaskContext *tc)
261{ 267{
268 struct GNUNET_MQ_Handle *mq = cls;
262 struct GNUNET_MQ_Envelope *current_envelope; 269 struct GNUNET_MQ_Envelope *current_envelope;
263 270
271 mq->continue_task = GNUNET_SCHEDULER_NO_TASK;
264 /* call is only valid if we're actually currently sending 272 /* call is only valid if we're actually currently sending
265 * a message */ 273 * a message */
266 current_envelope = mq->current_envelope; 274 current_envelope = mq->current_envelope;
@@ -284,6 +292,23 @@ GNUNET_MQ_impl_send_continue (struct GNUNET_MQ_Handle *mq)
284 292
285 293
286/** 294/**
295 * Call the send implementation for the next queued message,
296 * if any.
297 * Only useful for implementing message queues,
298 * results in undefined behavior if not used carefully.
299 *
300 * @param mq message queue to send the next message with
301 */
302void
303GNUNET_MQ_impl_send_continue (struct GNUNET_MQ_Handle *mq)
304{
305 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == mq->continue_task);
306 mq->continue_task = GNUNET_SCHEDULER_add_now (&impl_send_continue,
307 mq);
308}
309
310
311/**
287 * Create a message queue for the specified handlers. 312 * Create a message queue for the specified handlers.
288 * 313 *
289 * @param send function the implements sending messages 314 * @param send function the implements sending messages
@@ -435,7 +460,6 @@ transmit_queued (void *cls, size_t size,
435} 460}
436 461
437 462
438
439static void 463static void
440server_client_destroy_impl (struct GNUNET_MQ_Handle *mq, 464server_client_destroy_impl (struct GNUNET_MQ_Handle *mq,
441 void *impl_state) 465 void *impl_state)
@@ -448,6 +472,7 @@ server_client_destroy_impl (struct GNUNET_MQ_Handle *mq,
448 GNUNET_free (state); 472 GNUNET_free (state);
449} 473}
450 474
475
451static void 476static void
452server_client_send_impl (struct GNUNET_MQ_Handle *mq, 477server_client_send_impl (struct GNUNET_MQ_Handle *mq,
453 const struct GNUNET_MessageHeader *msg, void *impl_state) 478 const struct GNUNET_MessageHeader *msg, void *impl_state)
@@ -513,13 +538,14 @@ handle_client_message (void *cls,
513 * Transmit a queued message to the session's client. 538 * Transmit a queued message to the session's client.
514 * 539 *
515 * @param cls consensus session 540 * @param cls consensus session
516 * @param size number of bytes available in buf 541 * @param size number of bytes available in @a buf
517 * @param buf where the callee should write the message 542 * @param buf where the callee should write the message
518 * @return number of bytes written to buf 543 * @return number of bytes written to buf
519 */ 544 */
520static size_t 545static size_t
521connection_client_transmit_queued (void *cls, size_t size, 546connection_client_transmit_queued (void *cls,
522 void *buf) 547 size_t size,
548 void *buf)
523{ 549{
524 struct GNUNET_MQ_Handle *mq = cls; 550 struct GNUNET_MQ_Handle *mq = cls;
525 const struct GNUNET_MessageHeader *msg; 551 const struct GNUNET_MessageHeader *msg;
@@ -555,13 +581,13 @@ connection_client_transmit_queued (void *cls, size_t size,
555} 581}
556 582
557 583
558
559static void 584static void
560connection_client_destroy_impl (struct GNUNET_MQ_Handle *mq, void *impl_state) 585connection_client_destroy_impl (struct GNUNET_MQ_Handle *mq, void *impl_state)
561{ 586{
562 GNUNET_free (impl_state); 587 GNUNET_free (impl_state);
563} 588}
564 589
590
565static void 591static void
566connection_client_send_impl (struct GNUNET_MQ_Handle *mq, 592connection_client_send_impl (struct GNUNET_MQ_Handle *mq,
567 const struct GNUNET_MessageHeader *msg, void *impl_state) 593 const struct GNUNET_MessageHeader *msg, void *impl_state)
@@ -641,7 +667,6 @@ GNUNET_MQ_assoc_add (struct GNUNET_MQ_Handle *mq,
641} 667}
642 668
643 669
644
645void * 670void *
646GNUNET_MQ_assoc_get (struct GNUNET_MQ_Handle *mq, uint32_t request_id) 671GNUNET_MQ_assoc_get (struct GNUNET_MQ_Handle *mq, uint32_t request_id)
647{ 672{
@@ -681,7 +706,11 @@ GNUNET_MQ_destroy (struct GNUNET_MQ_Handle *mq)
681 { 706 {
682 mq->destroy_impl (mq, mq->impl_state); 707 mq->destroy_impl (mq, mq->impl_state);
683 } 708 }
684 709 if (GNUNET_SCHEDULER_NO_TASK != mq->continue_task)
710 {
711 GNUNET_SCHEDULER_cancel (mq->continue_task);
712 mq->continue_task = GNUNET_SCHEDULER_NO_TASK;
713 }
685 while (NULL != mq->envelope_head) 714 while (NULL != mq->envelope_head)
686 { 715 {
687 struct GNUNET_MQ_Envelope *ev; 716 struct GNUNET_MQ_Envelope *ev;