[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r33271 - gnunet/src/peerstore
From: |
gnunet |
Subject: |
[GNUnet-SVN] r33271 - gnunet/src/peerstore |
Date: |
Wed, 14 May 2014 00:20:02 +0200 |
Author: otarabai
Date: 2014-05-14 00:20:01 +0200 (Wed, 14 May 2014)
New Revision: 33271
Modified:
gnunet/src/peerstore/peerstore_api.c
Log:
reconnect on error
Modified: gnunet/src/peerstore/peerstore_api.c
===================================================================
--- gnunet/src/peerstore/peerstore_api.c 2014-05-13 22:08:22 UTC (rev
33270)
+++ gnunet/src/peerstore/peerstore_api.c 2014-05-13 22:20:01 UTC (rev
33271)
@@ -58,6 +58,11 @@
{
/**
+ * Handle to the PEERSTORE service.
+ */
+ struct GNUNET_PEERSTORE_Handle *h;
+
+ /**
* Continuation called with service response
*/
GNUNET_PEERSTORE_Continuation cont;
@@ -74,6 +79,25 @@
/******************************************************************************/
/**
+ * Close the existing connection to PEERSTORE and reconnect.
+ *
+ * @param h handle to the service
+ */
+static void
+reconnect (struct GNUNET_PEERSTORE_Handle *h)
+{
+
+ LOG(GNUNET_ERROR_TYPE_DEBUG, "Reconnecting...\n");
+ if (NULL != h->client)
+ {
+ GNUNET_CLIENT_disconnect (h->client);
+ h->client = NULL;
+ }
+ h->client = GNUNET_CLIENT_connect ("peerstore", h->cfg);
+
+}
+
+/**
* Connect to the PEERSTORE service.
*
* @return NULL on error
@@ -120,7 +144,7 @@
/**
* When a response for store request is received
*
- * @param cls unused
+ * @param cls a 'struct GNUNET_PEERSTORE_StoreContext *'
* @param msg message received, NULL on timeout or fatal error
*/
void store_response_receiver (void *cls, const struct GNUNET_MessageHeader
*msg)
@@ -133,6 +157,7 @@
if(NULL == msg)
{
sc->cont(sc->cont_cls, GNUNET_SYSERR);
+ reconnect(sc->h);
return;
}
msg_type = ntohs(msg->type);
@@ -196,6 +221,7 @@
sc = GNUNET_new(struct GNUNET_PEERSTORE_StoreContext);
sc->cont = cont;
sc->cont_cls = cont_cls;
+ sc->h = h;
ss_size = strlen(sub_system) + 1;
key_size = strlen(key) + 1;
request_size = sizeof(struct StoreRequestMessage) +
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r33271 - gnunet/src/peerstore,
gnunet <=