[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r21249 - in gnunet/src: statistics util
From: |
gnunet |
Subject: |
[GNUnet-SVN] r21249 - in gnunet/src: statistics util |
Date: |
Thu, 3 May 2012 16:03:39 +0200 |
Author: grothoff
Date: 2012-05-03 16:03:39 +0200 (Thu, 03 May 2012)
New Revision: 21249
Modified:
gnunet/src/statistics/statistics_api.c
gnunet/src/util/server.c
Log:
-fixing #2299
Modified: gnunet/src/statistics/statistics_api.c
===================================================================
--- gnunet/src/statistics/statistics_api.c 2012-05-03 13:49:55 UTC (rev
21248)
+++ gnunet/src/statistics/statistics_api.c 2012-05-03 14:03:39 UTC (rev
21249)
@@ -559,6 +559,16 @@
}
+static void
+destroy_task (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ struct GNUNET_STATISTICS_Handle *h = cls;
+
+ GNUNET_STATISTICS_destroy (h, GNUNET_YES);
+}
+
+
/**
* Function called with messages from stats service.
*
@@ -582,6 +592,19 @@
}
switch (ntohs (msg->type))
{
+ case GNUNET_MESSAGE_TYPE_TEST:
+ if (GNUNET_SYSERR != h->do_destroy)
+ {
+ /* not in shutdown, why do we get 'TEST'? */
+ GNUNET_break (0);
+ do_disconnect (h);
+ reconnect_later (h);
+ return;
+ }
+ h->do_destroy = GNUNET_NO;
+ GNUNET_SCHEDULER_add_continuation (&destroy_task, h,
+ GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+ break;
case GNUNET_MESSAGE_TYPE_STATISTICS_END:
LOG (GNUNET_ERROR_TYPE_DEBUG, "Received end of statistics marker\n");
if (NULL == (c = h->current))
@@ -951,13 +974,37 @@
}
-static void
-destroy_task (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+/**
+ * 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;
- GNUNET_STATISTICS_destroy (h, GNUNET_YES);
+ 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));
+ return sizeof (struct GNUNET_MessageHeader);
}
@@ -987,9 +1034,12 @@
{
if (h->do_destroy)
{
- h->do_destroy = GNUNET_NO;
- GNUNET_SCHEDULER_add_continuation (&destroy_task, h,
- GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+ h->do_destroy = GNUNET_SYSERR; /* in 'TEST' mode */
+ h->th = GNUNET_CLIENT_notify_transmit_ready (h->client,
+ sizeof (struct
GNUNET_MessageHeader),
+ SET_TRANSMIT_TIMEOUT,
+ GNUNET_NO,
+ &transmit_test_on_shutdown,
h);
}
return;
}
Modified: gnunet/src/util/server.c
===================================================================
--- gnunet/src/util/server.c 2012-05-03 13:49:55 UTC (rev 21248)
+++ gnunet/src/util/server.c 2012-05-03 14:03:39 UTC (rev 21249)
@@ -1285,6 +1285,7 @@
client->receive_pending = GNUNET_NO;
}
rc = client->reference_count;
+ client->reference_count++; /* make sure nobody else clean up client... */
if ( (GNUNET_YES != client->shutdown_now) &&
(NULL != server) )
{
@@ -1319,6 +1320,7 @@
GNUNET_SERVER_mst_destroy (client->mst);
client->mst = NULL;
}
+ client->reference_count--;
if (rc > 0)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r21249 - in gnunet/src: statistics util,
gnunet <=