aboutsummaryrefslogtreecommitdiff
path: root/src/datastore
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-08-07 16:55:16 +0000
committerChristian Grothoff <christian@grothoff.org>2010-08-07 16:55:16 +0000
commitb9de10a83f130b2c0a4513a1f713d778fbb4ecc1 (patch)
tree0dcfa912e2eea217d494ba56f1373e2c0cbb7e26 /src/datastore
parentd4115af6385dcab2433b27796e777819e297dae7 (diff)
downloadgnunet-b9de10a83f130b2c0a4513a1f713d778fbb4ecc1.tar.gz
gnunet-b9de10a83f130b2c0a4513a1f713d778fbb4ecc1.zip
do not fail if datastore unavailable
Diffstat (limited to 'src/datastore')
-rw-r--r--src/datastore/datastore_api.c11
-rw-r--r--src/datastore/gnunet-service-datastore.c1
-rw-r--r--src/datastore/perf_datastore_api.c41
-rw-r--r--src/datastore/perf_plugin_datastore.c20
-rw-r--r--src/datastore/perf_plugin_datastore_data_mysql.conf1
-rw-r--r--src/datastore/test_datastore_api.c42
-rw-r--r--src/datastore/test_datastore_api_management.c41
7 files changed, 130 insertions, 27 deletions
diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c
index dcafeb839..aaad7118f 100644
--- a/src/datastore/datastore_api.c
+++ b/src/datastore/datastore_api.c
@@ -682,14 +682,13 @@ process_status_message (void *cls,
682 if (msg == NULL) 682 if (msg == NULL)
683 { 683 {
684 free_queue_entry (qe); 684 free_queue_entry (qe);
685 rc.cont (rc.cont_cls,
686 GNUNET_SYSERR,
687 _("Failed to receive response from database."));
685 if (NULL == h->client) 688 if (NULL == h->client)
686 return; /* forced disconnect */ 689 return; /* forced disconnect */
687 if (was_transmitted == GNUNET_YES) 690 if (was_transmitted == GNUNET_YES)
688 { 691 do_disconnect (h);
689 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
690 _("Failed to receive response from database.\n"));
691 do_disconnect (h);
692 }
693 return; 692 return;
694 } 693 }
695 GNUNET_assert (GNUNET_YES == qe->was_transmitted); 694 GNUNET_assert (GNUNET_YES == qe->was_transmitted);
@@ -1079,7 +1078,7 @@ process_result_message (void *cls,
1079 1078
1080 h->in_receive = GNUNET_NO; 1079 h->in_receive = GNUNET_NO;
1081 if (msg == NULL) 1080 if (msg == NULL)
1082 { 1081 {
1083 was_transmitted = qe->was_transmitted; 1082 was_transmitted = qe->was_transmitted;
1084 free_queue_entry (qe); 1083 free_queue_entry (qe);
1085 if (was_transmitted == GNUNET_YES) 1084 if (was_transmitted == GNUNET_YES)
diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c
index 34cb70906..40ea153de 100644
--- a/src/datastore/gnunet-service-datastore.c
+++ b/src/datastore/gnunet-service-datastore.c
@@ -1623,7 +1623,6 @@ run (void *cls,
1623 GNUNET_SCHEDULER_add_delayed (sched, 1623 GNUNET_SCHEDULER_add_delayed (sched,
1624 GNUNET_TIME_UNIT_FOREVER_REL, 1624 GNUNET_TIME_UNIT_FOREVER_REL,
1625 &cleaning_task, NULL); 1625 &cleaning_task, NULL);
1626
1627} 1626}
1628 1627
1629 1628
diff --git a/src/datastore/perf_datastore_api.c b/src/datastore/perf_datastore_api.c
index 61724e964..741878309 100644
--- a/src/datastore/perf_datastore_api.c
+++ b/src/datastore/perf_datastore_api.c
@@ -314,6 +314,29 @@ run_continuation (void *cls,
314} 314}
315 315
316 316
317
318static void
319run_tests (void *cls,
320 int success,
321 const char *msg)
322{
323 struct CpsRunContext *crc = cls;
324
325 if (success != GNUNET_YES)
326 {
327 fprintf (stderr,
328 "Test 'put' operation failed with error `%s' database likely not setup, skipping test.",
329 msg);
330 GNUNET_free (crc);
331 return;
332 }
333 GNUNET_SCHEDULER_add_continuation (crc->sched,
334 &run_continuation,
335 crc,
336 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
337}
338
339
317static void 340static void
318run (void *cls, 341run (void *cls,
319 struct GNUNET_SCHEDULER_Handle *sched, 342 struct GNUNET_SCHEDULER_Handle *sched,
@@ -322,6 +345,7 @@ run (void *cls,
322 const struct GNUNET_CONFIGURATION_Handle *cfg) 345 const struct GNUNET_CONFIGURATION_Handle *cfg)
323{ 346{
324 struct CpsRunContext *crc; 347 struct CpsRunContext *crc;
348 static GNUNET_HashCode zkey;
325 349
326 datastore = GNUNET_DATASTORE_connect (cfg, sched); 350 datastore = GNUNET_DATASTORE_connect (cfg, sched);
327 start_time = GNUNET_TIME_absolute_get (); 351 start_time = GNUNET_TIME_absolute_get ();
@@ -329,10 +353,19 @@ run (void *cls,
329 crc->sched = sched; 353 crc->sched = sched;
330 crc->cfg = cfg; 354 crc->cfg = cfg;
331 crc->phase = RP_PUT; 355 crc->phase = RP_PUT;
332 GNUNET_SCHEDULER_add_continuation (crc->sched, 356 if (NULL ==
333 &run_continuation, 357 GNUNET_DATASTORE_put (datastore, 0,
334 crc, 358 &zkey, 4, "TEST",
335 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 359 GNUNET_BLOCK_TYPE_TEST,
360 0, 0, GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS),
361 0, 1, GNUNET_TIME_UNIT_MINUTES,
362 &run_tests, crc))
363 {
364 fprintf (stderr,
365 "Test 'put' operation failed.\n");
366 ok = 1;
367 GNUNET_free (crc);
368 }
336} 369}
337 370
338 371
diff --git a/src/datastore/perf_plugin_datastore.c b/src/datastore/perf_plugin_datastore.c
index 660f256f9..17cd009bc 100644
--- a/src/datastore/perf_plugin_datastore.c
+++ b/src/datastore/perf_plugin_datastore.c
@@ -334,7 +334,13 @@ load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg,
334 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 334 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
335 _("Loading `%s' datastore plugin\n"), name); 335 _("Loading `%s' datastore plugin\n"), name);
336 GNUNET_asprintf (&libname, "libgnunet_plugin_datastore_%s", name); 336 GNUNET_asprintf (&libname, "libgnunet_plugin_datastore_%s", name);
337 GNUNET_assert (NULL != (ret = GNUNET_PLUGIN_load (libname, &env))); 337 if (NULL == (ret = GNUNET_PLUGIN_load (libname, &env)))
338 {
339 fprintf (stderr,
340 "Failed to load plugin `%s'!\n",
341 name);
342 return NULL;
343 }
338 GNUNET_free (libname); 344 GNUNET_free (libname);
339 GNUNET_free (name); 345 GNUNET_free (name);
340 return ret; 346 return ret;
@@ -352,15 +358,19 @@ run (void *cls,
352 struct CpsRunContext *crc; 358 struct CpsRunContext *crc;
353 359
354 api = load_plugin (c, s); 360 api = load_plugin (c, s);
355 GNUNET_assert (api != NULL); 361 if (api == NULL)
362 {
363 fprintf (stderr,
364 "Could not initialize plugin, assuming database not configured. Test not run!\n");
365 return;
366 }
356 crc = GNUNET_malloc(sizeof(struct CpsRunContext)); 367 crc = GNUNET_malloc(sizeof(struct CpsRunContext));
357 crc->api = api; 368 crc->api = api;
358 crc->sched = s; 369 crc->sched = s;
359 crc->cfg = c; 370 crc->cfg = c;
360 crc->phase = RP_PUT; 371 crc->phase = RP_PUT;
361 GNUNET_SCHEDULER_add_after (s, 372 GNUNET_SCHEDULER_add_now (crc->sched,
362 GNUNET_SCHEDULER_NO_TASK, 373 &test, crc);
363 &test, crc);
364} 374}
365 375
366 376
diff --git a/src/datastore/perf_plugin_datastore_data_mysql.conf b/src/datastore/perf_plugin_datastore_data_mysql.conf
index a9daec189..d436ea53d 100644
--- a/src/datastore/perf_plugin_datastore_data_mysql.conf
+++ b/src/datastore/perf_plugin_datastore_data_mysql.conf
@@ -21,6 +21,7 @@ DATABASE = mysql
21# REJECT_FROM6 = 21# REJECT_FROM6 =
22# PREFIX = 22# PREFIX =
23 23
24
24[dht] 25[dht]
25AUTOSTART = NO 26AUTOSTART = NO
26 27
diff --git a/src/datastore/test_datastore_api.c b/src/datastore/test_datastore_api.c
index 000601df3..0ea3c4c86 100644
--- a/src/datastore/test_datastore_api.c
+++ b/src/datastore/test_datastore_api.c
@@ -583,6 +583,28 @@ run_continuation (void *cls,
583 583
584 584
585static void 585static void
586run_tests (void *cls,
587 int success,
588 const char *msg)
589{
590 struct CpsRunContext *crc = cls;
591
592 if (success != GNUNET_YES)
593 {
594 fprintf (stderr,
595 "Test 'put' operation failed with error `%s' database likely not setup, skipping test.",
596 msg);
597 GNUNET_free (crc);
598 return;
599 }
600 GNUNET_SCHEDULER_add_continuation (crc->sched,
601 &run_continuation,
602 crc,
603 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
604}
605
606
607static void
586run (void *cls, 608run (void *cls,
587 struct GNUNET_SCHEDULER_Handle *sched, 609 struct GNUNET_SCHEDULER_Handle *sched,
588 char *const *args, 610 char *const *args,
@@ -590,6 +612,7 @@ run (void *cls,
590 const struct GNUNET_CONFIGURATION_Handle *cfg) 612 const struct GNUNET_CONFIGURATION_Handle *cfg)
591{ 613{
592 struct CpsRunContext *crc; 614 struct CpsRunContext *crc;
615 static GNUNET_HashCode zkey;
593 616
594 crc = GNUNET_malloc(sizeof(struct CpsRunContext)); 617 crc = GNUNET_malloc(sizeof(struct CpsRunContext));
595 crc->sched = sched; 618 crc->sched = sched;
@@ -597,15 +620,22 @@ run (void *cls,
597 crc->phase = RP_PUT; 620 crc->phase = RP_PUT;
598 now = GNUNET_TIME_absolute_get (); 621 now = GNUNET_TIME_absolute_get ();
599 datastore = GNUNET_DATASTORE_connect (cfg, sched); 622 datastore = GNUNET_DATASTORE_connect (cfg, sched);
600 GNUNET_SCHEDULER_add_continuation (crc->sched, 623 if (NULL ==
601 &run_continuation, 624 GNUNET_DATASTORE_put (datastore, 0,
602 crc, 625 &zkey, 4, "TEST",
603 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 626 GNUNET_BLOCK_TYPE_TEST,
604 627 0, 0, GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS),
628 0, 1, GNUNET_TIME_UNIT_MINUTES,
629 &run_tests, crc))
630 {
631 fprintf (stderr,
632 "Test 'put' operation failed.\n");
633 ok = 1;
634 GNUNET_free (crc);
635 }
605} 636}
606 637
607 638
608
609static int 639static int
610check () 640check ()
611{ 641{
diff --git a/src/datastore/test_datastore_api_management.c b/src/datastore/test_datastore_api_management.c
index d0278094f..3de1544f3 100644
--- a/src/datastore/test_datastore_api_management.c
+++ b/src/datastore/test_datastore_api_management.c
@@ -293,6 +293,28 @@ run_continuation (void *cls,
293 293
294 294
295static void 295static void
296run_tests (void *cls,
297 int success,
298 const char *msg)
299{
300 struct CpsRunContext *crc = cls;
301
302 if (success != GNUNET_YES)
303 {
304 fprintf (stderr,
305 "Test 'put' operation failed with error `%s' database likely not setup, skipping test.",
306 msg);
307 GNUNET_free (crc);
308 return;
309 }
310 GNUNET_SCHEDULER_add_continuation (crc->sched,
311 &run_continuation,
312 crc,
313 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
314}
315
316
317static void
296run (void *cls, 318run (void *cls,
297 struct GNUNET_SCHEDULER_Handle *sched, 319 struct GNUNET_SCHEDULER_Handle *sched,
298 char *const *args, 320 char *const *args,
@@ -300,6 +322,7 @@ run (void *cls,
300 const struct GNUNET_CONFIGURATION_Handle *cfg) 322 const struct GNUNET_CONFIGURATION_Handle *cfg)
301{ 323{
302 struct CpsRunContext *crc; 324 struct CpsRunContext *crc;
325 static GNUNET_HashCode zkey;
303 326
304 crc = GNUNET_malloc(sizeof(struct CpsRunContext)); 327 crc = GNUNET_malloc(sizeof(struct CpsRunContext));
305 crc->sched = sched; 328 crc->sched = sched;
@@ -307,11 +330,19 @@ run (void *cls,
307 crc->phase = RP_PUT; 330 crc->phase = RP_PUT;
308 now = GNUNET_TIME_absolute_get (); 331 now = GNUNET_TIME_absolute_get ();
309 datastore = GNUNET_DATASTORE_connect (cfg, sched); 332 datastore = GNUNET_DATASTORE_connect (cfg, sched);
310 GNUNET_SCHEDULER_add_continuation (crc->sched, 333 if (NULL ==
311 &run_continuation, 334 GNUNET_DATASTORE_put (datastore, 0,
312 crc, 335 &zkey, 4, "TEST",
313 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 336 GNUNET_BLOCK_TYPE_TEST,
314 337 0, 0, GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS),
338 0, 1, GNUNET_TIME_UNIT_MINUTES,
339 &run_tests, crc))
340 {
341 fprintf (stderr,
342 "Test 'put' operation failed.\n");
343 GNUNET_free (crc);
344 ok = 1;
345 }
315} 346}
316 347
317 348