diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-08-07 16:55:16 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-08-07 16:55:16 +0000 |
commit | b9de10a83f130b2c0a4513a1f713d778fbb4ecc1 (patch) | |
tree | 0dcfa912e2eea217d494ba56f1373e2c0cbb7e26 | |
parent | d4115af6385dcab2433b27796e777819e297dae7 (diff) | |
download | gnunet-b9de10a83f130b2c0a4513a1f713d778fbb4ecc1.tar.gz gnunet-b9de10a83f130b2c0a4513a1f713d778fbb4ecc1.zip |
do not fail if datastore unavailable
-rw-r--r-- | contrib/defaults.conf | 1 | ||||
-rw-r--r-- | src/datastore/datastore_api.c | 11 | ||||
-rw-r--r-- | src/datastore/gnunet-service-datastore.c | 1 | ||||
-rw-r--r-- | src/datastore/perf_datastore_api.c | 41 | ||||
-rw-r--r-- | src/datastore/perf_plugin_datastore.c | 20 | ||||
-rw-r--r-- | src/datastore/perf_plugin_datastore_data_mysql.conf | 1 | ||||
-rw-r--r-- | src/datastore/test_datastore_api.c | 42 | ||||
-rw-r--r-- | src/datastore/test_datastore_api_management.c | 41 | ||||
-rw-r--r-- | src/include/gnunet_block_lib.h | 4 | ||||
-rw-r--r-- | src/include/gnunet_fs_service.h | 17 | ||||
-rw-r--r-- | src/util/bio.c | 10 |
11 files changed, 157 insertions, 32 deletions
diff --git a/contrib/defaults.conf b/contrib/defaults.conf index 016870466..74efa2260 100644 --- a/contrib/defaults.conf +++ b/contrib/defaults.conf | |||
@@ -211,6 +211,7 @@ INDEXDB = $SERVICEHOME/idxinfo.lst | |||
211 | TRUST = $SERVICEHOME/data/credit/ | 211 | TRUST = $SERVICEHOME/data/credit/ |
212 | IDENTITY_DIR = $SERVICEHOME/identities/ | 212 | IDENTITY_DIR = $SERVICEHOME/identities/ |
213 | STATE_DIR = $SERVICEHOME/persistence/ | 213 | STATE_DIR = $SERVICEHOME/persistence/ |
214 | UPDATE_DIR = $SERVICEHOME/updates/ | ||
214 | PORT = 2094 | 215 | PORT = 2094 |
215 | HOSTNAME = localhost | 216 | HOSTNAME = localhost |
216 | HOME = $SERVICEHOME | 217 | HOME = $SERVICEHOME |
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 | |||
318 | static void | ||
319 | run_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 | |||
317 | static void | 340 | static void |
318 | run (void *cls, | 341 | run (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] |
25 | AUTOSTART = NO | 26 | AUTOSTART = 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 | ||
585 | static void | 585 | static void |
586 | run_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 | |||
607 | static void | ||
586 | run (void *cls, | 608 | run (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 | |||
609 | static int | 639 | static int |
610 | check () | 640 | check () |
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 | ||
295 | static void | 295 | static void |
296 | run_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 | |||
317 | static void | ||
296 | run (void *cls, | 318 | run (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 | ||
diff --git a/src/include/gnunet_block_lib.h b/src/include/gnunet_block_lib.h index eebbb2f68..0bd9848d7 100644 --- a/src/include/gnunet_block_lib.h +++ b/src/include/gnunet_block_lib.h | |||
@@ -75,7 +75,9 @@ enum GNUNET_BLOCK_Type | |||
75 | /** | 75 | /** |
76 | * Type of a block that is used to advertise a namespace. | 76 | * Type of a block that is used to advertise a namespace. |
77 | */ | 77 | */ |
78 | GNUNET_BLOCK_TYPE_NBLOCK = 6 | 78 | GNUNET_BLOCK_TYPE_NBLOCK = 6, |
79 | |||
80 | GNUNET_BLOCK_TYPE_TEST = 9999 | ||
79 | 81 | ||
80 | }; | 82 | }; |
81 | 83 | ||
diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h index 3f3b2b981..758a4895c 100644 --- a/src/include/gnunet_fs_service.h +++ b/src/include/gnunet_fs_service.h | |||
@@ -2243,15 +2243,28 @@ typedef void | |||
2243 | 2243 | ||
2244 | 2244 | ||
2245 | /** | 2245 | /** |
2246 | * List all of the identifiers in the namespace for | 2246 | * List all of the identifiers in the namespace for which we could |
2247 | * which we could produce an update. | 2247 | * produce an update. Namespace updates form a graph where each node |
2248 | * has a name. Each node can have any number of URI/meta-data entries | ||
2249 | * which can each be linked to other nodes. Cycles are possible. | ||
2250 | * | ||
2251 | * Calling this function with "next_id" NULL will cause the library to | ||
2252 | * call "ip" with a root for each strongly connected component of the | ||
2253 | * graph (a root being a node from which all other nodes in the Scc | ||
2254 | * are reachable). | ||
2255 | * | ||
2256 | * Calling this function with "next_id" being the name of a node will | ||
2257 | * cause the library to call "ip" with all children of the node. Note | ||
2258 | * that cycles within an SCC are possible (including self-loops). | ||
2248 | * | 2259 | * |
2249 | * @param namespace namespace to inspect for updateable content | 2260 | * @param namespace namespace to inspect for updateable content |
2261 | * @param next_id ID to look for; use NULL to look for SCC roots | ||
2250 | * @param ip function to call on each updateable identifier | 2262 | * @param ip function to call on each updateable identifier |
2251 | * @param ip_cls closure for ip | 2263 | * @param ip_cls closure for ip |
2252 | */ | 2264 | */ |
2253 | void | 2265 | void |
2254 | GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Namespace *namespace, | 2266 | GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Namespace *namespace, |
2267 | const char *next_id, | ||
2255 | GNUNET_FS_IdentifierProcessor ip, | 2268 | GNUNET_FS_IdentifierProcessor ip, |
2256 | void *ip_cls); | 2269 | void *ip_cls); |
2257 | 2270 | ||
diff --git a/src/util/bio.c b/src/util/bio.c index 059638ff1..3fc7d05e6 100644 --- a/src/util/bio.c +++ b/src/util/bio.c | |||
@@ -79,10 +79,16 @@ GNUNET_BIO_read_open (const char *fn) | |||
79 | int | 79 | int |
80 | GNUNET_BIO_read_close (struct GNUNET_BIO_ReadHandle *h, char **emsg) | 80 | GNUNET_BIO_read_close (struct GNUNET_BIO_ReadHandle *h, char **emsg) |
81 | { | 81 | { |
82 | *emsg = h->emsg; | 82 | int err; |
83 | |||
84 | err = (NULL == h->emsg) ? GNUNET_OK : GNUNET_SYSERR; | ||
85 | if (emsg != NULL) | ||
86 | *emsg = h->emsg; | ||
87 | else | ||
88 | GNUNET_free_non_null (h->emsg); | ||
83 | GNUNET_DISK_file_close (h->fd); | 89 | GNUNET_DISK_file_close (h->fd); |
84 | GNUNET_free (h); | 90 | GNUNET_free (h); |
85 | return (NULL == *emsg) ? GNUNET_OK : GNUNET_SYSERR; | 91 | return err; |
86 | } | 92 | } |
87 | 93 | ||
88 | 94 | ||