aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-12-24 01:32:27 +0000
committerChristian Grothoff <christian@grothoff.org>2014-12-24 01:32:27 +0000
commit25380f86d1739bd73db86cea90154eec6175b7d5 (patch)
tree474ecc6bcfa4fdeda36950e021e6bcd2cfd67c51
parentf1f603c7d0b3f03dca46a4f313472288eb080eb1 (diff)
downloadgnunet-25380f86d1739bd73db86cea90154eec6175b7d5.tar.gz
gnunet-25380f86d1739bd73db86cea90154eec6175b7d5.zip
-delay serving requests until plugin is ready
-rw-r--r--src/datastore/gnunet-service-datastore.c55
1 files changed, 31 insertions, 24 deletions
diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c
index ac0b5c0db..71d436999 100644
--- a/src/datastore/gnunet-service-datastore.c
+++ b/src/datastore/gnunet-service-datastore.c
@@ -285,6 +285,10 @@ static int cleaning_done;
285 */ 285 */
286static struct GNUNET_STATISTICS_GetHandle *stat_get; 286static struct GNUNET_STATISTICS_GetHandle *stat_get;
287 287
288/**
289 * Handle to our server.
290 */
291static struct GNUNET_SERVER_Handle *server;
288 292
289/** 293/**
290 * Task that is used to remove expired entries from 294 * Task that is used to remove expired entries from
@@ -1361,6 +1365,28 @@ add_key_to_bloomfilter (void *cls,
1361static void 1365static void
1362process_stat_done (void *cls, int success) 1366process_stat_done (void *cls, int success)
1363{ 1367{
1368 static const struct GNUNET_SERVER_MessageHandler handlers[] = {
1369 {&handle_reserve, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_RESERVE,
1370 sizeof (struct ReserveMessage)},
1371 {&handle_release_reserve, NULL,
1372 GNUNET_MESSAGE_TYPE_DATASTORE_RELEASE_RESERVE,
1373 sizeof (struct ReleaseReserveMessage)},
1374 {&handle_put, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_PUT, 0},
1375 {&handle_update, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_UPDATE,
1376 sizeof (struct UpdateMessage)},
1377 {&handle_get, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_GET, 0},
1378 {&handle_get_replication, NULL,
1379 GNUNET_MESSAGE_TYPE_DATASTORE_GET_REPLICATION,
1380 sizeof (struct GNUNET_MessageHeader)},
1381 {&handle_get_zero_anonymity, NULL,
1382 GNUNET_MESSAGE_TYPE_DATASTORE_GET_ZERO_ANONYMITY,
1383 sizeof (struct GetZeroAnonymityMessage)},
1384 {&handle_remove, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_REMOVE, 0},
1385 {&handle_drop, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_DROP,
1386 sizeof (struct GNUNET_MessageHeader)},
1387 {NULL, NULL, 0, 0}
1388 };
1389
1364 stat_get = NULL; 1390 stat_get = NULL;
1365 plugin = load_plugin (); 1391 plugin = load_plugin ();
1366 if (NULL == plugin) 1392 if (NULL == plugin)
@@ -1395,6 +1421,8 @@ process_stat_done (void *cls, int success)
1395 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1421 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1396 _("Bloomfilter construction complete.\n")); 1422 _("Bloomfilter construction complete.\n"));
1397 } 1423 }
1424
1425 GNUNET_SERVER_add_handlers (server, handlers);
1398 expired_kill_task 1426 expired_kill_task
1399 = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, 1427 = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
1400 &delete_expired, 1428 &delete_expired,
@@ -1503,39 +1531,19 @@ cleanup_reservations (void *cls,
1503 * Process datastore requests. 1531 * Process datastore requests.
1504 * 1532 *
1505 * @param cls closure 1533 * @param cls closure
1506 * @param server the initialized server 1534 * @param serv the initialized server
1507 * @param c configuration to use 1535 * @param c configuration to use
1508 */ 1536 */
1509static void 1537static void
1510run (void *cls, 1538run (void *cls,
1511 struct GNUNET_SERVER_Handle *server, 1539 struct GNUNET_SERVER_Handle *serv,
1512 const struct GNUNET_CONFIGURATION_Handle *c) 1540 const struct GNUNET_CONFIGURATION_Handle *c)
1513{ 1541{
1514 static const struct GNUNET_SERVER_MessageHandler handlers[] = {
1515 {&handle_reserve, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_RESERVE,
1516 sizeof (struct ReserveMessage)},
1517 {&handle_release_reserve, NULL,
1518 GNUNET_MESSAGE_TYPE_DATASTORE_RELEASE_RESERVE,
1519 sizeof (struct ReleaseReserveMessage)},
1520 {&handle_put, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_PUT, 0},
1521 {&handle_update, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_UPDATE,
1522 sizeof (struct UpdateMessage)},
1523 {&handle_get, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_GET, 0},
1524 {&handle_get_replication, NULL,
1525 GNUNET_MESSAGE_TYPE_DATASTORE_GET_REPLICATION,
1526 sizeof (struct GNUNET_MessageHeader)},
1527 {&handle_get_zero_anonymity, NULL,
1528 GNUNET_MESSAGE_TYPE_DATASTORE_GET_ZERO_ANONYMITY,
1529 sizeof (struct GetZeroAnonymityMessage)},
1530 {&handle_remove, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_REMOVE, 0},
1531 {&handle_drop, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_DROP,
1532 sizeof (struct GNUNET_MessageHeader)},
1533 {NULL, NULL, 0, 0}
1534 };
1535 char *fn; 1542 char *fn;
1536 char *pfn; 1543 char *pfn;
1537 unsigned int bf_size; 1544 unsigned int bf_size;
1538 1545
1546 server = serv;
1539 cfg = c; 1547 cfg = c;
1540 if (GNUNET_OK != 1548 if (GNUNET_OK !=
1541 GNUNET_CONFIGURATION_get_value_string (cfg, "DATASTORE", "DATABASE", 1549 GNUNET_CONFIGURATION_get_value_string (cfg, "DATASTORE", "DATABASE",
@@ -1656,7 +1664,6 @@ run (void *cls,
1656 GNUNET_SERVER_disconnect_notify (server, 1664 GNUNET_SERVER_disconnect_notify (server,
1657 &cleanup_reservations, 1665 &cleanup_reservations,
1658 NULL); 1666 NULL);
1659 GNUNET_SERVER_add_handlers (server, handlers);
1660 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 1667 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
1661 &cleaning_task, 1668 &cleaning_task,
1662 NULL); 1669 NULL);