From 4ab9f527078552f8a26008f6856fec0b21607a54 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 8 Jul 2016 16:32:50 +0000 Subject: add GNUNET_MQ_set_handlers_closure API --- src/include/gnunet_mq_lib.h | 12 ++++++++++++ src/util/mq.c | 24 ++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/include/gnunet_mq_lib.h b/src/include/gnunet_mq_lib.h index 7da5aa778..43cefca9f 100644 --- a/src/include/gnunet_mq_lib.h +++ b/src/include/gnunet_mq_lib.h @@ -535,6 +535,18 @@ GNUNET_MQ_queue_for_callbacks (GNUNET_MQ_SendImpl send, void *cls); +/** + * Change the closure argument in all of the `handlers` of the + * @a mq. + * + * @param mq to modify + * @param handlers_cls new closure to use + */ +void +GNUNET_MQ_set_handlers_closure (struct GNUNET_MQ_Handle *mq, + void *handlers_cls); + + /** * Call a callback once the envelope has been sent, that is, * sending it can not be canceled anymore. diff --git a/src/util/mq.c b/src/util/mq.c index 185fe5170..b9bc4f2f1 100644 --- a/src/util/mq.c +++ b/src/util/mq.c @@ -472,6 +472,26 @@ GNUNET_MQ_queue_for_callbacks (GNUNET_MQ_SendImpl send, } +/** + * Change the closure argument in all of the `handlers` of the + * @a mq. + * + * @param mq to modify + * @param handlers_cls new closure to use + */ +void +GNUNET_MQ_set_handlers_closure (struct GNUNET_MQ_Handle *mq, + void *handlers_cls) +{ + unsigned int i; + + if (NULL == mq->handlers) + return; + for (i=0;NULL != mq->handlers[i].cb; i++) + mq->handlers[i].cls = handlers_cls; +} + + /** * Get the message that should currently be sent. * Fails if there is no current message. @@ -662,8 +682,8 @@ GNUNET_MQ_queue_for_server_client (struct GNUNET_SERVER_Client *client) mq->impl_state = scss; scss->client = client; GNUNET_SERVER_client_keep (client); - mq->send_impl = server_client_send_impl; - mq->destroy_impl = server_client_destroy_impl; + mq->send_impl = &server_client_send_impl; + mq->destroy_impl = &server_client_destroy_impl; return mq; } -- cgit v1.2.3