+ GNUNET_assert (NULL == expire_task);
+ expire_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
+ (GNUNET_TIME_UNIT_SECONDS,
+ EXPIRED_RECORDS_CLEANUP_INTERVAL),
+ &cleanup_expired_records,
+ NULL);
+ }
+}
+
+
+/**
+ * Continuation to expire_records called by the peerstore plugin
+ *
+ * @param cls unused
+ * @param success count of records deleted or #GNUNET_SYSERR
+ */
+static void
+expire_records_continuation (void *cls,
+ int success)
+{
+ if (success > 0)
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "%d records expired.\n",
+ success);
+ GNUNET_assert (NULL == expire_task);
+ expire_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
+ (GNUNET_TIME_UNIT_SECONDS,
+ EXPIRED_RECORDS_CLEANUP_INTERVAL),
+ &cleanup_expired_records,
+ NULL);
+}
+
+
+/**
+ * A client disconnected. Remove all of its data structure entries.
+ *
+ * @param cls closure, NULL
+ * @param client identification of the client
+ * @param mq the message queue
+ * @return
+ */
+static void *
+client_connect_cb (void *cls,
+ struct GNUNET_SERVICE_Client *client,
+ struct GNUNET_MQ_Handle *mq)
+{
+ num_clients++;
+ return client;
+}
+
+
+/**
+ * Search for a disconnected client and remove it
+ *
+ * @param cls closuer, a `struct GNUNET_SERVICE_Client`
+ * @param key hash of record key
+ * @param value the watcher client, a `struct GNUNET_SERVICE_Client *`
+ * @return #GNUNET_OK to continue iterating
+ */
+static int
+client_disconnect_it (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
+{
+ if (value == cls)
+ {
+ GNUNET_CONTAINER_multihashmap_remove (watchers,
+ key,
+ value);
+ num_clients++;