[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r37947 - in gnunet/src: include nse util
From: |
gnunet |
Subject: |
[GNUnet-SVN] r37947 - in gnunet/src: include nse util |
Date: |
Mon, 19 Sep 2016 16:31:14 +0200 |
Author: grothoff
Date: 2016-09-19 16:31:14 +0200 (Mon, 19 Sep 2016)
New Revision: 37947
Modified:
gnunet/src/include/gnunet_mq_lib.h
gnunet/src/nse/gnunet-service-nse.c
gnunet/src/util/mq.c
Log:
towards adding mq destruction notification
Modified: gnunet/src/include/gnunet_mq_lib.h
===================================================================
--- gnunet/src/include/gnunet_mq_lib.h 2016-09-19 13:26:44 UTC (rev 37946)
+++ gnunet/src/include/gnunet_mq_lib.h 2016-09-19 14:31:14 UTC (rev 37947)
@@ -637,6 +637,36 @@
/**
+ * Handle we return for callbacks registered to be
+ * notified when #GNUNET_MQ_destroy() is called on a queue.
+ */
+struct GNUNET_MQ_DestroyNotificationHandle;
+
+
+/**
+ * Register function to be called whenever @a mq is being
+ * destroyed.
+ *
+ * @param mq message queue to watch
+ * @param cb function to call on @a mq destruction
+ * @param cb_cls closure for @a cb
+ * @return handle for #GNUNET_MQ_destroy_notify_cancel().
+ */
+struct GNUNET_MQ_DestroyNotificationHandle *
+GNUNET_MQ_destroy_notify (struct GNUNET_MQ_Handle *mq,
+ GNUNET_SCHEDULER_TaskCallback cb,
+ void *cb_cls);
+
+/**
+ * Cancel registration from #GNUNET_MQ_destroy_notify().
+ *
+ * @param dnh handle for registration to cancel
+ */
+void
+GNUNET_MQ_destroy_notify_cancel (struct GNUNET_MQ_DestroyNotificationHandle
*dnh);
+
+
+/**
* Call the message message handler that was registered
* for the type of the given message in the given message queue.
*
Modified: gnunet/src/nse/gnunet-service-nse.c
===================================================================
--- gnunet/src/nse/gnunet-service-nse.c 2016-09-19 13:26:44 UTC (rev 37946)
+++ gnunet/src/nse/gnunet-service-nse.c 2016-09-19 14:31:14 UTC (rev 37947)
@@ -276,12 +276,12 @@
/**
* Task scheduled to update our flood message for the next round.
*/
-static struct GNUNET_SCHEDULER_Task * flood_task;
+static struct GNUNET_SCHEDULER_Task *flood_task;
/**
* Task scheduled to compute our proof.
*/
-static struct GNUNET_SCHEDULER_Task * proof_task;
+static struct GNUNET_SCHEDULER_Task *proof_task;
/**
* Notification context, simplifies client broadcasts.
Modified: gnunet/src/util/mq.c
===================================================================
--- gnunet/src/util/mq.c 2016-09-19 13:26:44 UTC (rev 37946)
+++ gnunet/src/util/mq.c 2016-09-19 14:31:14 UTC (rev 37947)
@@ -155,6 +155,16 @@
struct GNUNET_SCHEDULER_Task *continue_task;
/**
+ * Functions to call on queue destruction; kept in a DLL.
+ */
+ struct GNUNET_MQ_DestroyNotificationHandle *dnh_head;
+
+ /**
+ * Functions to call on queue destruction; kept in a DLL.
+ */
+ struct GNUNET_MQ_DestroyNotificationHandle *dnh_tail;
+
+ /**
* Additional options buffer set for this queue by
* #GNUNET_MQ_set_options(). Default is 0.
*/
@@ -1173,4 +1183,81 @@
}
+/**
+ * Handle we return for callbacks registered to be
+ * notified when #GNUNET_MQ_destroy() is called on a queue.
+ */
+struct GNUNET_MQ_DestroyNotificationHandle
+{
+ /**
+ * Kept in a DLL.
+ */
+ struct GNUNET_MQ_DestroyNotificationHandle *prev;
+
+ /**
+ * Kept in a DLL.
+ */
+ struct GNUNET_MQ_DestroyNotificationHandle *next;
+
+ /**
+ * Queue to notify about.
+ */
+ struct GNUNET_MQ_Handle *mq;
+
+ /**
+ * Function to call.
+ */
+ GNUNET_SCHEDULER_TaskCallback cb;
+
+ /**
+ * Closure for @e cb.
+ */
+ void *cb_cls;
+};
+
+
+/**
+ * Register function to be called whenever @a mq is being
+ * destroyed.
+ *
+ * @param mq message queue to watch
+ * @param cb function to call on @a mq destruction
+ * @param cb_cls closure for @a cb
+ * @return handle for #GNUNET_MQ_destroy_notify_cancel().
+ */
+struct GNUNET_MQ_DestroyNotificationHandle *
+GNUNET_MQ_destroy_notify (struct GNUNET_MQ_Handle *mq,
+ GNUNET_SCHEDULER_TaskCallback cb,
+ void *cb_cls)
+{
+ struct GNUNET_MQ_DestroyNotificationHandle *dnh;
+
+ dnh = GNUNET_new (struct GNUNET_MQ_DestroyNotificationHandle);
+ dnh->mq = mq;
+ dnh->cb = cb;
+ dnh->cb_cls = cb_cls;
+ GNUNET_CONTAINER_DLL_insert (mq->dnh_head,
+ mq->dnh_tail,
+ dnh);
+ return dnh;
+}
+
+
+/**
+ * Cancel registration from #GNUNET_MQ_destroy_notify().
+ *
+ * @param dnh handle for registration to cancel
+ */
+void
+GNUNET_MQ_destroy_notify_cancel (struct GNUNET_MQ_DestroyNotificationHandle
*dnh)
+{
+ struct GNUNET_MQ_Handle *mq = dnh->mq;
+
+ GNUNET_CONTAINER_DLL_remove (mq->dnh_head,
+ mq->dnh_tail,
+ dnh);
+ GNUNET_free (dnh);
+}
+
+
/* end of mq.c */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r37947 - in gnunet/src: include nse util,
gnunet <=