minor changes for address conversion
[oweals/gnunet.git] / src / util / bandwidth.c
index 87716478979365ad1837565bce768a2ce4b85e38..18b846869372ff86670fbb8e4e2961ede2524399 100644 (file)
@@ -132,7 +132,9 @@ excess_trigger (void *cls,
   struct GNUNET_BANDWIDTH_Tracker *av = cls;
 
   av->excess_task = GNUNET_SCHEDULER_NO_TASK;
-  av->excess_cb (av->excess_cb_cls);
+
+  if (NULL != av->excess_cb)
+    av->excess_cb (av->excess_cb_cls);
 }
 
 
@@ -194,6 +196,9 @@ update_excess (struct GNUNET_BANDWIDTH_Tracker *av)
  * ignored and replaced by #GNUNET_SERVER_MAX_MESSAGE_SIZE (which is in
  * bytes).
  *
+ * To stop notifications about updates and excess callbacks use
+ * #GNUNET_BANDWIDTH_tracker_notification_stop
+ *
  * @param av tracker to initialize
  * @param update_cb callback to notify a client about the tracker being updated
  * @param update_cb_cls cls for the callback
@@ -260,6 +265,25 @@ GNUNET_BANDWIDTH_tracker_init (struct GNUNET_BANDWIDTH_Tracker *av,
 }
 
 
+/**
+ * Stop notifying about tracker updates and excess notifications
+ *
+ * @param av the respective trackers
+ */
+void
+GNUNET_BANDWIDTH_tracker_notification_stop (struct GNUNET_BANDWIDTH_Tracker *av)
+{
+  if (GNUNET_SCHEDULER_NO_TASK != av->excess_task)
+    GNUNET_SCHEDULER_cancel (av->excess_task);
+  av->excess_task = GNUNET_SCHEDULER_NO_TASK;
+  av->excess_cb = NULL;
+  av->excess_cb_cls = NULL;
+  av->update_cb = NULL;
+  av->update_cb_cls = NULL;
+}
+
+
+
 /**
  * Update the tracker, looking at the current time and
  * bandwidth consumption data.