aboutsummaryrefslogtreecommitdiff
path: root/src/datastore/datastore_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-08-03 10:29:09 +0000
committerChristian Grothoff <christian@grothoff.org>2015-08-03 10:29:09 +0000
commit722a93c626d4033abbb221f44238fd7e25f99b0d (patch)
tree3cc42f7c84a90e4e9eb3ce64a2b804aba43e6b53 /src/datastore/datastore_api.c
parent1b49daf277669a740f2a0a2dc78dd637832b552f (diff)
downloadgnunet-722a93c626d4033abbb221f44238fd7e25f99b0d.tar.gz
gnunet-722a93c626d4033abbb221f44238fd7e25f99b0d.zip
-reduce autostarting for tests, reduce timeouts
Diffstat (limited to 'src/datastore/datastore_api.c')
-rw-r--r--src/datastore/datastore_api.c52
1 files changed, 35 insertions, 17 deletions
diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c
index d7e933fc6..a5b3e9088 100644
--- a/src/datastore/datastore_api.c
+++ b/src/datastore/datastore_api.c
@@ -328,7 +328,8 @@ transmit_drop (void *cls, size_t size, void *buf)
328 * @param drop set to #GNUNET_YES to delete all data in datastore (!) 328 * @param drop set to #GNUNET_YES to delete all data in datastore (!)
329 */ 329 */
330void 330void
331GNUNET_DATASTORE_disconnect (struct GNUNET_DATASTORE_Handle *h, int drop) 331GNUNET_DATASTORE_disconnect (struct GNUNET_DATASTORE_Handle *h,
332 int drop)
332{ 333{
333 struct GNUNET_DATASTORE_QueueEntry *qe; 334 struct GNUNET_DATASTORE_QueueEntry *qe;
334 335
@@ -338,12 +339,12 @@ GNUNET_DATASTORE_disconnect (struct GNUNET_DATASTORE_Handle *h, int drop)
338 GNUNET_CLIENT_notify_transmit_ready_cancel (h->th); 339 GNUNET_CLIENT_notify_transmit_ready_cancel (h->th);
339 h->th = NULL; 340 h->th = NULL;
340 } 341 }
341 if (h->client != NULL) 342 if (NULL != h->client)
342 { 343 {
343 GNUNET_CLIENT_disconnect (h->client); 344 GNUNET_CLIENT_disconnect (h->client);
344 h->client = NULL; 345 h->client = NULL;
345 } 346 }
346 if (h->reconnect_task != NULL) 347 if (NULL != h->reconnect_task)
347 { 348 {
348 GNUNET_SCHEDULER_cancel (h->reconnect_task); 349 GNUNET_SCHEDULER_cancel (h->reconnect_task);
349 h->reconnect_task = NULL; 350 h->reconnect_task = NULL;
@@ -356,21 +357,23 @@ GNUNET_DATASTORE_disconnect (struct GNUNET_DATASTORE_Handle *h, int drop)
356 if (GNUNET_YES == drop) 357 if (GNUNET_YES == drop)
357 { 358 {
358 h->client = GNUNET_CLIENT_connect ("datastore", h->cfg); 359 h->client = GNUNET_CLIENT_connect ("datastore", h->cfg);
359 if (h->client != NULL) 360 if (NULL != h->client)
360 { 361 {
361 if (NULL != 362 if (NULL !=
362 GNUNET_CLIENT_notify_transmit_ready (h->client, 363 GNUNET_CLIENT_notify_transmit_ready (h->client,
363 sizeof (struct 364 sizeof (struct
364 GNUNET_MessageHeader), 365 GNUNET_MessageHeader),
365 GNUNET_TIME_UNIT_MINUTES, 366 GNUNET_TIME_UNIT_SECONDS,
366 GNUNET_YES, &transmit_drop, h)) 367 GNUNET_YES,
368 &transmit_drop, h))
367 return; 369 return;
368 GNUNET_CLIENT_disconnect (h->client); 370 GNUNET_CLIENT_disconnect (h->client);
369 h->client = NULL; 371 h->client = NULL;
370 } 372 }
371 GNUNET_break (0); 373 GNUNET_break (0);
372 } 374 }
373 GNUNET_STATISTICS_destroy (h->stats, GNUNET_NO); 375 GNUNET_STATISTICS_destroy (h->stats,
376 GNUNET_NO);
374 h->stats = NULL; 377 h->stats = NULL;
375 GNUNET_free (h); 378 GNUNET_free (h);
376} 379}
@@ -396,8 +399,12 @@ timeout_queue_entry (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
396 LOG (GNUNET_ERROR_TYPE_DEBUG, 399 LOG (GNUNET_ERROR_TYPE_DEBUG,
397 "Timeout of request in datastore queue\n"); 400 "Timeout of request in datastore queue\n");
398 /* response_proc's expect request at the head of the queue! */ 401 /* response_proc's expect request at the head of the queue! */
399 GNUNET_CONTAINER_DLL_remove (h->queue_head, h->queue_tail, qe); 402 GNUNET_CONTAINER_DLL_remove (h->queue_head,
400 GNUNET_CONTAINER_DLL_insert (h->queue_head, h->queue_tail, qe); 403 h->queue_tail,
404 qe);
405 GNUNET_CONTAINER_DLL_insert (h->queue_head,
406 h->queue_tail,
407 qe);
401 GNUNET_assert (h->queue_head == qe); 408 GNUNET_assert (h->queue_head == qe);
402 qe->response_proc (qe->h, NULL); 409 qe->response_proc (qe->h, NULL);
403} 410}
@@ -418,8 +425,10 @@ timeout_queue_entry (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
418 * @return NULL if the queue is full 425 * @return NULL if the queue is full
419 */ 426 */
420static struct GNUNET_DATASTORE_QueueEntry * 427static struct GNUNET_DATASTORE_QueueEntry *
421make_queue_entry (struct GNUNET_DATASTORE_Handle *h, size_t msize, 428make_queue_entry (struct GNUNET_DATASTORE_Handle *h,
422 unsigned int queue_priority, unsigned int max_queue_size, 429 size_t msize,
430 unsigned int queue_priority,
431 unsigned int max_queue_size,
423 struct GNUNET_TIME_Relative timeout, 432 struct GNUNET_TIME_Relative timeout,
424 GNUNET_CLIENT_MessageHandler response_proc, 433 GNUNET_CLIENT_MessageHandler response_proc,
425 const union QueueContext *qc) 434 const union QueueContext *qc)
@@ -856,13 +865,18 @@ process_status_message (void *cls,
856 * (or rather, will already have been invoked) 865 * (or rather, will already have been invoked)
857 */ 866 */
858struct GNUNET_DATASTORE_QueueEntry * 867struct GNUNET_DATASTORE_QueueEntry *
859GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h, uint32_t rid, 868GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h,
860 const struct GNUNET_HashCode * key, size_t size, 869 uint32_t rid,
861 const void *data, enum GNUNET_BLOCK_Type type, 870 const struct GNUNET_HashCode *key,
862 uint32_t priority, uint32_t anonymity, 871 size_t size,
872 const void *data,
873 enum GNUNET_BLOCK_Type type,
874 uint32_t priority,
875 uint32_t anonymity,
863 uint32_t replication, 876 uint32_t replication,
864 struct GNUNET_TIME_Absolute expiration, 877 struct GNUNET_TIME_Absolute expiration,
865 unsigned int queue_priority, unsigned int max_queue_size, 878 unsigned int queue_priority,
879 unsigned int max_queue_size,
866 struct GNUNET_TIME_Relative timeout, 880 struct GNUNET_TIME_Relative timeout,
867 GNUNET_DATASTORE_ContinuationWithStatus cont, 881 GNUNET_DATASTORE_ContinuationWithStatus cont,
868 void *cont_cls) 882 void *cont_cls)
@@ -881,7 +895,11 @@ GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h, uint32_t rid,
881 GNUNET_assert (msize < GNUNET_SERVER_MAX_MESSAGE_SIZE); 895 GNUNET_assert (msize < GNUNET_SERVER_MAX_MESSAGE_SIZE);
882 qc.sc.cont = cont; 896 qc.sc.cont = cont;
883 qc.sc.cont_cls = cont_cls; 897 qc.sc.cont_cls = cont_cls;
884 qe = make_queue_entry (h, msize, queue_priority, max_queue_size, timeout, 898 qe = make_queue_entry (h,
899 msize,
900 queue_priority,
901 max_queue_size,
902 timeout,
885 &process_status_message, &qc); 903 &process_status_message, &qc);
886 if (qe == NULL) 904 if (qe == NULL)
887 { 905 {