aboutsummaryrefslogtreecommitdiff
path: root/src/peerstore/peerstore_api.c
diff options
context:
space:
mode:
authorOmar Tarabai <tarabai@devegypt.com>2014-05-12 10:10:41 +0000
committerOmar Tarabai <tarabai@devegypt.com>2014-05-12 10:10:41 +0000
commitd9cc0e96edf3637d292bf09671b216bf396faa36 (patch)
treebbbb0d642f73e817e5551f8c7f9de0a80343382c /src/peerstore/peerstore_api.c
parent54b5026b7bf917816bef12620f94715ae1dd6f78 (diff)
downloadgnunet-d9cc0e96edf3637d292bf09671b216bf396faa36.tar.gz
gnunet-d9cc0e96edf3637d292bf09671b216bf396faa36.zip
PEERSTORE api fix
Diffstat (limited to 'src/peerstore/peerstore_api.c')
-rw-r--r--src/peerstore/peerstore_api.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/peerstore/peerstore_api.c b/src/peerstore/peerstore_api.c
index f31a3b848..2ab7a7d34 100644
--- a/src/peerstore/peerstore_api.c
+++ b/src/peerstore/peerstore_api.c
@@ -204,6 +204,7 @@ reconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
204{ 204{
205 struct GNUNET_PEERSTORE_Handle *h = cls; 205 struct GNUNET_PEERSTORE_Handle *h = cls;
206 206
207 LOG(GNUNET_ERROR_TYPE_DEBUG, "Reconnect task executed\n");
207 h->r_task = GNUNET_SCHEDULER_NO_TASK; 208 h->r_task = GNUNET_SCHEDULER_NO_TASK;
208 reconnect (h); 209 reconnect (h);
209} 210}
@@ -225,6 +226,7 @@ GNUNET_PEERSTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
225 h = GNUNET_new (struct GNUNET_PEERSTORE_Handle); 226 h = GNUNET_new (struct GNUNET_PEERSTORE_Handle);
226 h->client = client; 227 h->client = client;
227 h->cfg = cfg; 228 h->cfg = cfg;
229 LOG(GNUNET_ERROR_TYPE_DEBUG, "New connection created\n");
228 return h; 230 return h;
229} 231}
230 232
@@ -242,6 +244,7 @@ GNUNET_PEERSTORE_disconnect(struct GNUNET_PEERSTORE_Handle *h)
242 h->client = NULL; 244 h->client = NULL;
243 } 245 }
244 GNUNET_free (h); 246 GNUNET_free (h);
247 LOG(GNUNET_ERROR_TYPE_DEBUG, "Disconnected, BYE!\n");
245} 248}
246 249
247/** 250/**
@@ -252,6 +255,7 @@ GNUNET_PEERSTORE_disconnect(struct GNUNET_PEERSTORE_Handle *h)
252static void 255static void
253reconnect (struct GNUNET_PEERSTORE_Handle *h) 256reconnect (struct GNUNET_PEERSTORE_Handle *h)
254{ 257{
258 LOG(GNUNET_ERROR_TYPE_DEBUG, "Reconnecting...\n");
255 if (GNUNET_SCHEDULER_NO_TASK != h->r_task) 259 if (GNUNET_SCHEDULER_NO_TASK != h->r_task)
256 { 260 {
257 GNUNET_SCHEDULER_cancel (h->r_task); 261 GNUNET_SCHEDULER_cancel (h->r_task);
@@ -403,6 +407,7 @@ peerstore_handler (void *cls, const struct GNUNET_MessageHeader *msg)
403 trigger_transmit (h); 407 trigger_transmit (h);
404 if (NULL != h->sc_head) 408 if (NULL != h->sc_head)
405 { 409 {
410 LOG(GNUNET_ERROR_TYPE_DEBUG, "Another store request awaiting response, triggering receive for it\n");
406 h->in_receive = GNUNET_YES; 411 h->in_receive = GNUNET_YES;
407 GNUNET_CLIENT_receive (h->client, 412 GNUNET_CLIENT_receive (h->client,
408 &peerstore_handler, 413 &peerstore_handler,
@@ -411,15 +416,14 @@ peerstore_handler (void *cls, const struct GNUNET_MessageHeader *msg)
411 } 416 }
412 if(NULL != cont) 417 if(NULL != cont)
413 { 418 {
414 srm = (struct StoreResponseMessage *)&msg[1]; 419 LOG(GNUNET_ERROR_TYPE_DEBUG, "Calling continuation of store request\n");
420 srm = (struct StoreResponseMessage *)msg;
415 emsg = NULL; 421 emsg = NULL;
416 if(GNUNET_NO == ntohs(srm->success)) 422 if(GNUNET_NO == ntohs(srm->success))
417 { 423 {
418 LOG(GNUNET_ERROR_TYPE_DEBUG, "Calling user callback with message: %s\n", emsg);
419 emsg = GNUNET_malloc(ntohs(srm->emsg_size)); 424 emsg = GNUNET_malloc(ntohs(srm->emsg_size));
420 memcpy(emsg, &srm[1], ntohs(srm->emsg_size)); 425 memcpy(emsg, &srm[1], ntohs(srm->emsg_size));
421 } 426 }
422 LOG(GNUNET_ERROR_TYPE_DEBUG, "Calling user callback without a message\n");
423 cont(cont_cls, emsg); 427 cont(cont_cls, emsg);
424 } 428 }
425 break; 429 break;