[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r17535 - gnunet/src/ats
From: |
gnunet |
Subject: |
[GNUnet-SVN] r17535 - gnunet/src/ats |
Date: |
Mon, 17 Oct 2011 13:28:28 +0200 |
Author: grothoff
Date: 2011-10-17 13:28:28 +0200 (Mon, 17 Oct 2011)
New Revision: 17535
Modified:
gnunet/src/ats/ats_api_performance.c
Log:
fix
Modified: gnunet/src/ats/ats_api_performance.c
===================================================================
--- gnunet/src/ats/ats_api_performance.c 2011-10-17 11:21:10 UTC (rev
17534)
+++ gnunet/src/ats/ats_api_performance.c 2011-10-17 11:28:28 UTC (rev
17535)
@@ -156,6 +156,11 @@
*/
struct GNUNET_CLIENT_TransmitHandle *th;
+ /**
+ * Task to trigger reconnect.
+ */
+ GNUNET_SCHEDULER_TaskIdentifier task;
+
};
@@ -169,6 +174,23 @@
/**
+ * Re-establish the connection to the ATS service.
+ *
+ * @param cls handle to use to re-connect.
+ * @param tc scheduler context
+ */
+static void
+reconnect_task (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ struct GNUNET_ATS_PerformanceHandle *ph = cls;
+
+ ph->task = GNUNET_SCHEDULER_NO_TASK;
+ reconnect (ph);
+}
+
+
+/**
* Transmit messages from the message queue to the service
* (if there are any, and if we are not already trying).
*
@@ -372,42 +394,31 @@
struct GNUNET_ATS_PerformanceHandle *ph = cls;
if (NULL == msg)
- {
- GNUNET_CLIENT_disconnect (ph->client, GNUNET_NO);
- ph->client = NULL;
- reconnect (ph);
- return;
- }
+ goto reconnect;
switch (ntohs (msg->type))
{
case GNUNET_MESSAGE_TYPE_ATS_PEER_INFORMATION:
if (GNUNET_OK != process_pi_message (ph, msg))
- {
- GNUNET_CLIENT_disconnect (ph->client, GNUNET_NO);
- ph->client = NULL;
- reconnect (ph);
- return;
- }
+ goto reconnect;
break;
case GNUNET_MESSAGE_TYPE_ATS_RESERVATION_RESULT:
if (GNUNET_OK != process_rr_message (ph, msg))
- {
- GNUNET_CLIENT_disconnect (ph->client, GNUNET_NO);
- ph->client = NULL;
- reconnect (ph);
- return;
- }
+ goto reconnect;
break;
default:
GNUNET_break (0);
- GNUNET_CLIENT_disconnect (ph->client, GNUNET_NO);
- ph->client = NULL;
- reconnect (ph);
+ goto reconnect;
return;
}
GNUNET_CLIENT_receive (ph->client,
&process_ats_message, ph,
GNUNET_TIME_UNIT_FOREVER_REL);
+ return;
+ reconnect:
+ GNUNET_CLIENT_disconnect (ph->client, GNUNET_NO);
+ ph->client = NULL;
+ ph->task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+ &reconnect_task, ph);
}
@@ -500,6 +511,11 @@
GNUNET_break (NULL == rc->rcb);
GNUNET_free (p);
}
+ if (GNUNET_SCHEDULER_NO_TASK != ph->task)
+ {
+ GNUNET_SCHEDULER_cancel (ph->task);
+ ph->task = GNUNET_SCHEDULER_NO_TASK;
+ }
GNUNET_CLIENT_disconnect (ph->client, GNUNET_NO);
GNUNET_free (ph);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r17535 - gnunet/src/ats,
gnunet <=