add GNUNET_MQ_set_handlers_closure API
authorChristian Grothoff <christian@grothoff.org>
Fri, 8 Jul 2016 16:32:50 +0000 (16:32 +0000)
committerChristian Grothoff <christian@grothoff.org>
Fri, 8 Jul 2016 16:32:50 +0000 (16:32 +0000)
src/include/gnunet_mq_lib.h
src/util/mq.c

index 7da5aa7787db8d721b38f580a6aa4a2c4e1b7873..43cefca9f1a17ef7b4232a2384ffd1d4b48197b3 100644 (file)
@@ -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.
index 185fe51704ed4c6e25162e022bb6fd964c56892e..b9bc4f2f1cafa7de86b438cbb3c4cedb0a41dc43 100644 (file)
@@ -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;
 }