+/**
+ * Function called to transmit TEST message to service to
+ * confirm that the service has received all of our 'SET'
+ * messages (during statistics disconnect/shutdown).
+ *
+ * @param cls the 'struct GNUNET_STATISTICS_Handle'
+ * @param size how many bytes can we write to buf
+ * @param buf where to write requests to the service
+ * @return number of bytes written to buf
+ */
+static size_t
+transmit_test_on_shutdown (void *cls,
+ size_t size,
+ void *buf)
+{
+ struct GNUNET_STATISTICS_Handle *h = cls;
+ struct GNUNET_MessageHeader hdr;
+
+ h->th = NULL;
+ if (NULL == buf)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ _("Failed to receive acknowledgement from statistics service, some statistics might have been lost!\n"));
+ h->do_destroy = GNUNET_NO;
+ GNUNET_SCHEDULER_add_continuation (&destroy_task, h,
+ GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+ return 0;
+ }
+ hdr.type = htons (GNUNET_MESSAGE_TYPE_TEST);
+ hdr.size = htons (sizeof (struct GNUNET_MessageHeader));
+ memcpy (buf, &hdr, sizeof (hdr));
+ if (GNUNET_YES != h->receiving)
+ {
+ h->receiving = GNUNET_YES;
+ GNUNET_CLIENT_receive (h->client, &receive_stats, h,
+ GNUNET_TIME_UNIT_FOREVER_REL);
+ }
+ return sizeof (struct GNUNET_MessageHeader);
+}
+
+