2 This file is part of GNUnet
3 Copyright (C) 2004-2014 GNUnet e.V.
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
22 * @file datastore/gnunet-service-datastore.c
23 * @brief Management for the datastore for files stored on a GNUnet node
24 * @author Christian Grothoff
28 #include "gnunet_util_lib.h"
29 #include "gnunet_protocols.h"
30 #include "gnunet_statistics_service.h"
31 #include "gnunet_datastore_plugin.h"
32 #include "datastore.h"
35 * How many messages do we queue at most per client?
37 #define MAX_PENDING 1024
40 * How long are we at most keeping "expired" content
41 * past the expiration date in the database?
43 #define MAX_EXPIRE_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15)
46 * How fast are we allowed to query the database for deleting
47 * expired content? (1 item per second).
49 #define MIN_EXPIRE_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
52 * Name under which we store current space consumption.
54 static char *quota_stat_name;
57 * Task to timeout stat GET.
59 static struct GNUNET_SCHEDULER_Task *stat_timeout_task;
62 * After how many payload-changing operations
63 * do we sync our statistics?
65 #define MAX_STAT_SYNC_LAG 50
69 * Our datastore plugin.
71 struct DatastorePlugin
75 * API of the transport as returned by the plugin's
76 * initialization function.
78 struct GNUNET_DATASTORE_PluginFunctions *api;
81 * Short name for the plugin (i.e. "sqlite").
86 * Name of the library (i.e. "gnunet_plugin_datastore_sqlite").
91 * Environment this transport service is using
94 struct GNUNET_DATASTORE_PluginEnvironment env;
100 * Linked list of active reservations.
102 struct ReservationList
106 * This is a linked list.
108 struct ReservationList *next;
111 * Client that made the reservation.
113 struct GNUNET_SERVER_Client *client;
116 * Number of bytes (still) reserved.
121 * Number of items (still) reserved.
126 * Reservation identifier.
135 * Our datastore plugin (NULL if not available).
137 static struct DatastorePlugin *plugin;
140 * Linked list of space reservations made by clients.
142 static struct ReservationList *reservations;
145 * Bloomfilter to quickly tell if we don't have the content.
147 static struct GNUNET_CONTAINER_BloomFilter *filter;
150 * Name of our plugin.
152 static char *plugin_name;
157 static const struct GNUNET_CONFIGURATION_Handle *cfg;
160 * Handle for reporting statistics.
162 static struct GNUNET_STATISTICS_Handle *stats;
165 * How much space are we using for the cache? (space available for
166 * insertions that will be instantly reclaimed by discarding less
167 * important content --- or possibly whatever we just inserted into
170 static unsigned long long cache_size;
173 * How much space have we currently reserved?
175 static unsigned long long reserved;
178 * How much data are we currently storing
181 static unsigned long long payload;
184 * Identity of the task that is used to delete
187 static struct GNUNET_SCHEDULER_Task * expired_kill_task;
190 * Minimum time that content should have to not be discarded instantly
191 * (time stamp of any content that we've been discarding recently to
192 * stay below the quota). FOREVER if we had to expire content with
195 static struct GNUNET_TIME_Absolute min_expiration;
198 * How much space are we allowed to use?
200 static unsigned long long quota;
203 * Should the database be dropped on exit?
208 * Should we refresh the BF when the DB is loaded?
210 static int refresh_bf;
213 * Number of updates that were made to the
214 * payload value since we last synchronized
215 * it with the statistics service.
217 static unsigned int last_sync;
220 * Did we get an answer from statistics?
222 static int stats_worked;
226 * Synchronize our utilization statistics with the
227 * statistics service.
232 GNUNET_STATISTICS_set (stats,
236 GNUNET_STATISTICS_set (stats,
237 "# utilization by current datastore",
245 * Context for transmitting replies to clients.
247 struct TransmitCallbackContext
251 * We keep these in a doubly-linked list (for cleanup).
253 struct TransmitCallbackContext *next;
256 * We keep these in a doubly-linked list (for cleanup).
258 struct TransmitCallbackContext *prev;
261 * The message that we're asked to transmit.
263 struct GNUNET_MessageHeader *msg;
266 * Handle for the transmission request.
268 struct GNUNET_SERVER_TransmitHandle *th;
271 * Client that we are transmitting to.
273 struct GNUNET_SERVER_Client *client;
279 * Head of the doubly-linked list (for cleanup).
281 static struct TransmitCallbackContext *tcc_head;
284 * Tail of the doubly-linked list (for cleanup).
286 static struct TransmitCallbackContext *tcc_tail;
289 * Have we already cleaned up the TCCs and are hence no longer
290 * willing (or able) to transmit anything to anyone?
292 static int cleaning_done;
295 * Handle for pending get request.
297 static struct GNUNET_STATISTICS_GetHandle *stat_get;
300 * Handle to our server.
302 static struct GNUNET_SERVER_Handle *server;
305 * Task that is used to remove expired entries from
306 * the datastore. This task will schedule itself
307 * again automatically to always delete all expired
310 * @param cls not used
313 delete_expired (void *cls);
317 * Iterate over the expired items stored in the datastore.
318 * Delete all expired items; once we have processed all
319 * expired items, re-schedule the "delete_expired" task.
321 * @param cls not used
322 * @param key key for the content
323 * @param size number of bytes in data
324 * @param data content stored
325 * @param type type of the content
326 * @param priority priority of the content
327 * @param anonymity anonymity-level for the content
328 * @param expiration expiration time for the content
329 * @param uid unique identifier for the datum;
330 * maybe 0 if no unique identifier is available
332 * @return #GNUNET_SYSERR to abort the iteration, #GNUNET_OK to continue
333 * (continue on call to "next", of course),
334 * #GNUNET_NO to delete the item and continue (if supported)
337 expired_processor (void *cls,
338 const struct GNUNET_HashCode *key,
341 enum GNUNET_BLOCK_Type type,
344 struct GNUNET_TIME_Absolute expiration,
347 struct GNUNET_TIME_Absolute now;
352 GNUNET_SCHEDULER_add_delayed_with_priority (MAX_EXPIRE_DELAY,
353 GNUNET_SCHEDULER_PRIORITY_IDLE,
354 &delete_expired, NULL);
355 return GNUNET_SYSERR;
357 now = GNUNET_TIME_absolute_get ();
358 if (expiration.abs_value_us > now.abs_value_us)
360 /* finished processing */
362 GNUNET_SCHEDULER_add_delayed_with_priority (MAX_EXPIRE_DELAY,
363 GNUNET_SCHEDULER_PRIORITY_IDLE,
364 &delete_expired, NULL);
365 return GNUNET_SYSERR;
367 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
368 "Deleting content `%s' of type %u that expired %s ago\n",
369 GNUNET_h2s (key), type,
370 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_difference (expiration,
373 min_expiration = now;
374 GNUNET_STATISTICS_update (stats,
375 gettext_noop ("# bytes expired"),
378 GNUNET_CONTAINER_bloomfilter_remove (filter, key);
380 GNUNET_SCHEDULER_add_delayed_with_priority (MIN_EXPIRE_DELAY,
381 GNUNET_SCHEDULER_PRIORITY_IDLE,
382 &delete_expired, NULL);
388 * Task that is used to remove expired entries from
389 * the datastore. This task will schedule itself
390 * again automatically to always delete all expired
393 * @param cls not used
396 delete_expired (void *cls)
398 expired_kill_task = NULL;
399 plugin->api->get_expiration (plugin->api->cls,
406 * An iterator over a set of items stored in the datastore
407 * that deletes until we're happy with respect to our quota.
410 * @param key key for the content
411 * @param size number of bytes in data
412 * @param data content stored
413 * @param type type of the content
414 * @param priority priority of the content
415 * @param anonymity anonymity-level for the content
416 * @param expiration expiration time for the content
417 * @param uid unique identifier for the datum;
418 * maybe 0 if no unique identifier is available
419 * @return #GNUNET_SYSERR to abort the iteration, #GNUNET_OK to continue
420 * (continue on call to "next", of course),
421 * #GNUNET_NO to delete the item and continue (if supported)
424 quota_processor (void *cls,
425 const struct GNUNET_HashCode *key,
428 enum GNUNET_BLOCK_Type type,
431 struct GNUNET_TIME_Absolute expiration,
434 unsigned long long *need = cls;
437 return GNUNET_SYSERR;
438 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
439 "Deleting %llu bytes of low-priority (%u) content `%s' of type %u at %s prior to expiration (still trying to free another %llu bytes)\n",
440 (unsigned long long) (size + GNUNET_DATASTORE_ENTRY_OVERHEAD),
441 (unsigned int) priority,
442 GNUNET_h2s (key), type,
443 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (expiration),
446 if (size + GNUNET_DATASTORE_ENTRY_OVERHEAD > *need)
449 *need -= size + GNUNET_DATASTORE_ENTRY_OVERHEAD;
451 min_expiration = GNUNET_TIME_UNIT_FOREVER_ABS;
453 min_expiration = expiration;
454 GNUNET_STATISTICS_update (stats,
455 gettext_noop ("# bytes purged (low-priority)"),
457 GNUNET_CONTAINER_bloomfilter_remove (filter, key);
463 * Manage available disk space by running tasks
464 * that will discard content if necessary. This
465 * function will be run whenever a request for
466 * "need" bytes of storage could only be satisfied
467 * by eating into the "cache" (and we want our cache
470 * @param need number of bytes of content that were
471 * placed into the "cache" (and hence the
472 * number of bytes that should be removed).
475 manage_space (unsigned long long need)
477 unsigned long long last;
479 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
480 "Asked to free up %llu bytes of cache space\n",
483 while ((need > 0) && (last != need))
486 plugin->api->get_expiration (plugin->api->cls,
494 * Function called to notify a client about the socket
495 * begin ready to queue more data. "buf" will be
496 * NULL and "size" zero if the socket was closed for
497 * writing in the meantime.
500 * @param size number of bytes available in buf
501 * @param buf where the callee should write the message
502 * @return number of bytes written to buf
505 transmit_callback (void *cls, size_t size, void *buf)
507 struct TransmitCallbackContext *tcc = cls;
511 GNUNET_CONTAINER_DLL_remove (tcc_head, tcc_tail, tcc);
512 msize = ntohs (tcc->msg->size);
515 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
516 _("Transmission to client failed!\n"));
517 GNUNET_SERVER_receive_done (tcc->client, GNUNET_SYSERR);
518 GNUNET_SERVER_client_drop (tcc->client);
519 GNUNET_free (tcc->msg);
523 GNUNET_assert (size >= msize);
524 memcpy (buf, tcc->msg, msize);
525 GNUNET_SERVER_receive_done (tcc->client, GNUNET_OK);
526 GNUNET_SERVER_client_drop (tcc->client);
527 GNUNET_free (tcc->msg);
534 * Transmit the given message to the client.
536 * @param client target of the message
537 * @param msg message to transmit, will be freed!
540 transmit (struct GNUNET_SERVER_Client *client, struct GNUNET_MessageHeader *msg)
542 struct TransmitCallbackContext *tcc;
544 if (GNUNET_YES == cleaning_done)
546 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
547 _("Shutdown in progress, aborting transmission.\n"));
548 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
552 tcc = GNUNET_new (struct TransmitCallbackContext);
554 tcc->client = client;
557 GNUNET_SERVER_notify_transmit_ready (client, ntohs (msg->size),
558 GNUNET_TIME_UNIT_FOREVER_REL,
559 &transmit_callback, tcc)))
562 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
567 GNUNET_SERVER_client_keep (client);
568 GNUNET_CONTAINER_DLL_insert (tcc_head, tcc_tail, tcc);
573 * Transmit a status code to the client.
575 * @param client receiver of the response
576 * @param code status code
577 * @param msg optional error message (can be NULL)
580 transmit_status (struct GNUNET_SERVER_Client *client, int code, const char *msg)
582 struct StatusMessage *sm;
585 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
586 "Transmitting `%s' message with value %d and message `%s'\n",
587 "STATUS", code, msg != NULL ? msg : "(none)");
588 slen = (msg == NULL) ? 0 : strlen (msg) + 1;
589 sm = GNUNET_malloc (sizeof (struct StatusMessage) + slen);
590 sm->header.size = htons (sizeof (struct StatusMessage) + slen);
591 sm->header.type = htons (GNUNET_MESSAGE_TYPE_DATASTORE_STATUS);
592 sm->status = htonl (code);
593 sm->min_expiration = GNUNET_TIME_absolute_hton (min_expiration);
595 memcpy (&sm[1], msg, slen);
596 transmit (client, &sm->header);
601 * Function that will transmit the given datastore entry
604 * @param cls closure, pointer to the client (of type GNUNET_SERVER_Client).
605 * @param key key for the content
606 * @param size number of bytes in data
607 * @param data content stored
608 * @param type type of the content
609 * @param priority priority of the content
610 * @param anonymity anonymity-level for the content
611 * @param expiration expiration time for the content
612 * @param uid unique identifier for the datum;
613 * maybe 0 if no unique identifier is available
615 * @return GNUNET_SYSERR to abort the iteration, GNUNET_OK to continue,
616 * GNUNET_NO to delete the item and continue (if supported)
619 transmit_item (void *cls, const struct GNUNET_HashCode * key, uint32_t size,
620 const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority,
621 uint32_t anonymity, struct GNUNET_TIME_Absolute expiration,
624 struct GNUNET_SERVER_Client *client = cls;
625 struct GNUNET_MessageHeader *end;
626 struct DataMessage *dm;
630 /* transmit 'DATA_END' */
631 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting `%s' message\n",
633 end = GNUNET_new (struct GNUNET_MessageHeader);
634 end->size = htons (sizeof (struct GNUNET_MessageHeader));
635 end->type = htons (GNUNET_MESSAGE_TYPE_DATASTORE_DATA_END);
636 transmit (client, end);
637 GNUNET_SERVER_client_drop (client);
640 GNUNET_assert (sizeof (struct DataMessage) + size <
641 GNUNET_SERVER_MAX_MESSAGE_SIZE);
642 dm = GNUNET_malloc (sizeof (struct DataMessage) + size);
643 dm->header.size = htons (sizeof (struct DataMessage) + size);
644 dm->header.type = htons (GNUNET_MESSAGE_TYPE_DATASTORE_DATA);
646 dm->size = htonl (size);
647 dm->type = htonl (type);
648 dm->priority = htonl (priority);
649 dm->anonymity = htonl (anonymity);
650 dm->replication = htonl (0);
651 dm->reserved = htonl (0);
652 dm->expiration = GNUNET_TIME_absolute_hton (expiration);
653 dm->uid = GNUNET_htonll (uid);
655 memcpy (&dm[1], data, size);
656 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
657 "Transmitting `%s' message for `%s' of type %u with expiration %s (in: %s)\n",
658 "DATA", GNUNET_h2s (key), type,
659 GNUNET_STRINGS_absolute_time_to_string (expiration),
660 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (expiration),
662 GNUNET_STATISTICS_update (stats,
663 gettext_noop ("# results found"),
666 transmit (client, &dm->header);
667 GNUNET_SERVER_client_drop (client);
673 * Handle RESERVE-message.
676 * @param client identification of the client
677 * @param message the actual message
680 handle_reserve (void *cls, struct GNUNET_SERVER_Client *client,
681 const struct GNUNET_MessageHeader *message)
684 * Static counter to produce reservation identifiers.
686 static int reservation_gen;
688 const struct ReserveMessage *msg = (const struct ReserveMessage *) message;
689 struct ReservationList *e;
690 unsigned long long used;
691 unsigned long long req;
695 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
696 "Processing RESERVE request\n");
697 amount = GNUNET_ntohll (msg->amount);
698 entries = ntohl (msg->entries);
699 used = payload + reserved;
701 amount + ((unsigned long long) GNUNET_DATASTORE_ENTRY_OVERHEAD) * entries;
702 if (used + req > quota)
705 used = quota; /* cheat a bit for error message (to avoid negative numbers) */
706 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
708 ("Insufficient space (%llu bytes are available) to satisfy `%s' request for %llu bytes\n"),
709 quota - used, "RESERVE", req);
710 if (cache_size < req)
712 /* TODO: document this in the FAQ; essentially, if this
713 * message happens, the insertion request could be blocked
714 * by less-important content from migration because it is
715 * larger than 1/8th of the overall available space, and
716 * we only reserve 1/8th for "fresh" insertions */
717 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
719 ("The requested amount (%llu bytes) is larger than the cache size (%llu bytes)\n"),
721 transmit_status (client, 0,
723 ("Insufficient space to satisfy request and "
724 "requested amount is larger than cache size"));
728 transmit_status (client, 0,
729 gettext_noop ("Insufficient space to satisfy request"));
734 GNUNET_STATISTICS_set (stats,
735 gettext_noop ("# reserved"),
738 e = GNUNET_new (struct ReservationList);
739 e->next = reservations;
743 e->entries = entries;
744 e->rid = ++reservation_gen;
745 if (reservation_gen < 0)
746 reservation_gen = 0; /* wrap around */
747 transmit_status (client, e->rid, NULL);
752 * Handle RELEASE_RESERVE-message.
755 * @param client identification of the client
756 * @param message the actual message
759 handle_release_reserve (void *cls,
760 struct GNUNET_SERVER_Client *client,
761 const struct GNUNET_MessageHeader *message)
763 const struct ReleaseReserveMessage *msg =
764 (const struct ReleaseReserveMessage *) message;
765 struct ReservationList *pos;
766 struct ReservationList *prev;
767 struct ReservationList *next;
768 int rid = ntohl (msg->rid);
769 unsigned long long rem;
771 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
772 "Processing RELEASE_RESERVE request\n");
775 while (NULL != (pos = next))
786 ((unsigned long long) GNUNET_DATASTORE_ENTRY_OVERHEAD) * pos->entries;
787 GNUNET_assert (reserved >= rem);
789 GNUNET_STATISTICS_set (stats,
790 gettext_noop ("# reserved"),
793 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
794 "Returning %llu remaining reserved bytes to storage pool\n",
797 transmit_status (client, GNUNET_OK, NULL);
803 transmit_status (client, GNUNET_SYSERR,
804 gettext_noop ("Could not find matching reservation"));
809 * Check that the given message is a valid data message.
811 * @return NULL if the message is not well-formed, otherwise the message
813 static const struct DataMessage *
814 check_data (const struct GNUNET_MessageHeader *message)
818 const struct DataMessage *dm;
820 size = ntohs (message->size);
821 if (size < sizeof (struct DataMessage))
826 dm = (const struct DataMessage *) message;
827 dsize = ntohl (dm->size);
828 if (size != dsize + sizeof (struct DataMessage))
838 * Context for a PUT request used to see if the content is
844 * Client to notify on completion.
846 struct GNUNET_SERVER_Client *client;
848 #if ! HAVE_UNALIGNED_64_ACCESS
852 /* followed by the 'struct DataMessage' */
860 * @param key key for the item stored
861 * @param size size of the item stored
862 * @param status #GNUNET_OK or #GNUNET_SYSERROR
863 * @param msg error message on error
866 put_continuation (void *cls,
867 const struct GNUNET_HashCode *key,
872 struct PutContext *pc = cls;
874 if (GNUNET_OK == status)
876 GNUNET_STATISTICS_update (stats,
877 gettext_noop ("# bytes stored"),
880 GNUNET_CONTAINER_bloomfilter_add (filter, key);
881 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
882 "Successfully stored %u bytes under key `%s'\n",
883 size, GNUNET_h2s (key));
885 transmit_status (pc->client, status, msg);
886 GNUNET_SERVER_client_drop (pc->client);
888 if (quota - reserved - cache_size < payload)
890 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
891 _("Need %llu bytes more space (%llu allowed, using %llu)\n"),
892 (unsigned long long) size + GNUNET_DATASTORE_ENTRY_OVERHEAD,
893 (unsigned long long) (quota - reserved - cache_size),
894 (unsigned long long) payload);
895 manage_space (size + GNUNET_DATASTORE_ENTRY_OVERHEAD);
901 * Actually put the data message.
903 * @param pc put context
906 execute_put (struct PutContext *pc)
908 const struct DataMessage *dm;
910 dm = (const struct DataMessage *) &pc[1];
911 plugin->api->put (plugin->api->cls, &dm->key, ntohl (dm->size), &dm[1],
912 ntohl (dm->type), ntohl (dm->priority),
913 ntohl (dm->anonymity), ntohl (dm->replication),
914 GNUNET_TIME_absolute_ntoh (dm->expiration),
915 &put_continuation, pc);
922 * @param status #GNUNET_OK or #GNUNET_SYSERR
923 * @param msg error message on error
926 check_present_continuation (void *cls,
930 struct GNUNET_SERVER_Client *client = cls;
932 transmit_status (client, GNUNET_NO, NULL);
933 GNUNET_SERVER_client_drop (client);
938 * Function that will check if the given datastore entry
939 * matches the put and if none match executes the put.
941 * @param cls closure, pointer to the client (of type `struct PutContext`).
942 * @param key key for the content
943 * @param size number of bytes in data
944 * @param data content stored
945 * @param type type of the content
946 * @param priority priority of the content
947 * @param anonymity anonymity-level for the content
948 * @param expiration expiration time for the content
949 * @param uid unique identifier for the datum;
950 * maybe 0 if no unique identifier is available
951 * @return #GNUNET_OK usually
952 * #GNUNET_NO to delete the item
955 check_present (void *cls,
956 const struct GNUNET_HashCode *key,
959 enum GNUNET_BLOCK_Type type,
962 struct GNUNET_TIME_Absolute expiration,
965 struct PutContext *pc = cls;
966 const struct DataMessage *dm;
968 dm = (const struct DataMessage *) &pc[1];
974 if ( (GNUNET_BLOCK_TYPE_FS_DBLOCK == type) ||
975 (GNUNET_BLOCK_TYPE_FS_IBLOCK == type) ||
976 ( (size == ntohl (dm->size)) &&
977 (0 == memcmp (&dm[1], data, size)) ) )
979 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
980 "Result already present in datastore\n");
981 /* FIXME: change API to allow increasing 'replication' counter */
982 if ((ntohl (dm->priority) > 0) ||
983 (GNUNET_TIME_absolute_ntoh (dm->expiration).abs_value_us >
984 expiration.abs_value_us))
985 plugin->api->update (plugin->api->cls,
987 (int32_t) ntohl (dm->priority),
988 GNUNET_TIME_absolute_ntoh (dm->expiration),
989 &check_present_continuation,
993 transmit_status (pc->client, GNUNET_NO, NULL);
994 GNUNET_SERVER_client_drop (pc->client);
1007 * Handle PUT-message.
1009 * @param cls closure
1010 * @param client identification of the client
1011 * @param message the actual message
1014 handle_put (void *cls,
1015 struct GNUNET_SERVER_Client *client,
1016 const struct GNUNET_MessageHeader *message)
1018 const struct DataMessage *dm = check_data (message);
1020 struct ReservationList *pos;
1021 struct PutContext *pc;
1022 struct GNUNET_HashCode vhash;
1025 if ((dm == NULL) || (ntohl (dm->type) == 0))
1028 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
1031 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1032 "Processing PUT request for `%s' of type %u\n",
1033 GNUNET_h2s (&dm->key),
1035 rid = ntohl (dm->rid);
1036 size = ntohl (dm->size);
1040 while ((NULL != pos) && (rid != pos->rid))
1042 GNUNET_break (pos != NULL);
1045 GNUNET_break (pos->entries > 0);
1046 GNUNET_break (pos->amount >= size);
1048 pos->amount -= size;
1049 reserved -= (size + GNUNET_DATASTORE_ENTRY_OVERHEAD);
1050 GNUNET_STATISTICS_set (stats,
1051 gettext_noop ("# reserved"),
1056 pc = GNUNET_malloc (sizeof (struct PutContext) + size +
1057 sizeof (struct DataMessage));
1058 pc->client = client;
1059 GNUNET_SERVER_client_keep (client);
1060 memcpy (&pc[1], dm, size + sizeof (struct DataMessage));
1061 if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (filter, &dm->key))
1063 GNUNET_CRYPTO_hash (&dm[1], size, &vhash);
1064 plugin->api->get_key (plugin->api->cls,
1078 * Handle #GNUNET_MESSAGE_TYPE_DATASTORE_GET-message.
1080 * @param cls closure
1081 * @param client identification of the client
1082 * @param message the actual message
1085 handle_get (void *cls,
1086 struct GNUNET_SERVER_Client *client,
1087 const struct GNUNET_MessageHeader *message)
1089 const struct GetMessage *msg;
1091 msg = (const struct GetMessage *) message;
1092 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1093 "Processing GET request of type %u\n",
1095 GNUNET_STATISTICS_update (stats,
1096 gettext_noop ("# GET requests received"),
1099 GNUNET_SERVER_client_keep (client);
1100 plugin->api->get_key (plugin->api->cls,
1101 GNUNET_ntohll (msg->offset),
1110 * Handle #GNUNET_MESSAGE_TYPE_DATASTORE_GET_KEY-message.
1112 * @param cls closure
1113 * @param client identification of the client
1114 * @param message the actual message
1117 handle_get_key (void *cls,
1118 struct GNUNET_SERVER_Client *client,
1119 const struct GNUNET_MessageHeader *message)
1121 const struct GetKeyMessage *msg;
1123 msg = (const struct GetKeyMessage *) message;
1124 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1125 "Processing GET request for `%s' of type %u\n",
1126 GNUNET_h2s (&msg->key),
1128 GNUNET_STATISTICS_update (stats,
1129 gettext_noop ("# GET KEY requests received"),
1132 GNUNET_SERVER_client_keep (client);
1134 GNUNET_CONTAINER_bloomfilter_test (filter,
1137 /* don't bother database... */
1138 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1139 "Empty result set for GET request for `%s' (bloomfilter).\n",
1140 GNUNET_h2s (&msg->key));
1141 GNUNET_STATISTICS_update (stats,
1143 ("# requests filtered by bloomfilter"),
1146 transmit_item (client,
1147 NULL, 0, NULL, 0, 0, 0,
1148 GNUNET_TIME_UNIT_ZERO_ABS,
1152 plugin->api->get_key (plugin->api->cls,
1153 GNUNET_ntohll (msg->offset),
1163 * Function called with the result of an update operation.
1165 * @param cls closure
1166 * @param status #GNUNET_OK or #GNUNET_SYSERR
1167 * @param msg error message on error
1170 update_continuation (void *cls,
1174 struct GNUNET_SERVER_Client *client = cls;
1176 transmit_status (client, status, msg);
1177 GNUNET_SERVER_client_drop (client);
1182 * Handle UPDATE-message.
1184 * @param cls closure
1185 * @param client identification of the client
1186 * @param message the actual message
1189 handle_update (void *cls,
1190 struct GNUNET_SERVER_Client *client,
1191 const struct GNUNET_MessageHeader *message)
1193 const struct UpdateMessage *msg;
1195 GNUNET_STATISTICS_update (stats,
1196 gettext_noop ("# UPDATE requests received"),
1199 msg = (const struct UpdateMessage *) message;
1200 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1201 "Processing UPDATE request for %llu\n",
1202 (unsigned long long) GNUNET_ntohll (msg->uid));
1203 GNUNET_SERVER_client_keep (client);
1204 plugin->api->update (plugin->api->cls,
1205 GNUNET_ntohll (msg->uid),
1206 (int32_t) ntohl (msg->priority),
1207 GNUNET_TIME_absolute_ntoh (msg->expiration),
1208 &update_continuation, client);
1213 * Handle GET_REPLICATION-message.
1215 * @param cls closure
1216 * @param client identification of the client
1217 * @param message the actual message
1220 handle_get_replication (void *cls,
1221 struct GNUNET_SERVER_Client *client,
1222 const struct GNUNET_MessageHeader *message)
1224 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1225 "Processing `%s' request\n",
1227 GNUNET_STATISTICS_update (stats,
1228 gettext_noop ("# GET REPLICATION requests received"),
1231 GNUNET_SERVER_client_keep (client);
1232 plugin->api->get_replication (plugin->api->cls,
1233 &transmit_item, client);
1238 * Handle GET_ZERO_ANONYMITY-message.
1240 * @param cls closure
1241 * @param client identification of the client
1242 * @param message the actual message
1245 handle_get_zero_anonymity (void *cls,
1246 struct GNUNET_SERVER_Client *client,
1247 const struct GNUNET_MessageHeader *message)
1249 const struct GetZeroAnonymityMessage *msg =
1250 (const struct GetZeroAnonymityMessage *) message;
1251 enum GNUNET_BLOCK_Type type;
1253 type = (enum GNUNET_BLOCK_Type) ntohl (msg->type);
1254 if (type == GNUNET_BLOCK_TYPE_ANY)
1257 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
1260 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1261 "Processing `%s' request\n",
1262 "GET_ZERO_ANONYMITY");
1263 GNUNET_STATISTICS_update (stats,
1264 gettext_noop ("# GET ZERO ANONYMITY requests received"),
1267 GNUNET_SERVER_client_keep (client);
1268 plugin->api->get_zero_anonymity (plugin->api->cls,
1269 GNUNET_ntohll (msg->offset),
1271 &transmit_item, client);
1276 * Callback function that will cause the item that is passed
1277 * in to be deleted (by returning #GNUNET_NO).
1279 * @param cls closure
1280 * @param key key for the content
1281 * @param size number of bytes in data
1282 * @param data content stored
1283 * @param type type of the content
1284 * @param priority priority of the content
1285 * @param anonymity anonymity-level for the content
1286 * @param expiration expiration time for the content
1287 * @param uid unique identifier for the datum
1288 * @return #GNUNET_OK to keep the item
1289 * #GNUNET_NO to delete the item
1292 remove_callback (void *cls,
1293 const struct GNUNET_HashCode *key,
1296 enum GNUNET_BLOCK_Type type,
1299 struct GNUNET_TIME_Absolute expiration,
1302 struct GNUNET_SERVER_Client *client = cls;
1306 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1307 "No further matches for REMOVE request.\n");
1308 transmit_status (client,
1310 _("Content not found"));
1311 GNUNET_SERVER_client_drop (client);
1312 return GNUNET_OK; /* last item */
1314 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1315 "Item %llu matches REMOVE request for key `%s' and type %u.\n",
1316 (unsigned long long) uid,
1319 GNUNET_STATISTICS_update (stats,
1320 gettext_noop ("# bytes removed (explicit request)"),
1323 GNUNET_CONTAINER_bloomfilter_remove (filter, key);
1324 transmit_status (client, GNUNET_OK, NULL);
1325 GNUNET_SERVER_client_drop (client);
1331 * Handle REMOVE-message.
1333 * @param cls closure
1334 * @param client identification of the client
1335 * @param message the actual message
1338 handle_remove (void *cls,
1339 struct GNUNET_SERVER_Client *client,
1340 const struct GNUNET_MessageHeader *message)
1342 const struct DataMessage *dm = check_data (message);
1343 struct GNUNET_HashCode vhash;
1348 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
1351 GNUNET_STATISTICS_update (stats,
1352 gettext_noop ("# REMOVE requests received"),
1354 GNUNET_SERVER_client_keep (client);
1355 GNUNET_CRYPTO_hash (&dm[1],
1358 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1359 "Processing REMOVE request for `%s' of type %u\n",
1360 GNUNET_h2s (&dm->key),
1362 plugin->api->get_key (plugin->api->cls,
1366 (enum GNUNET_BLOCK_Type) ntohl (dm->type),
1367 &remove_callback, client);
1372 * Handle DROP-message.
1374 * @param cls closure
1375 * @param client identification of the client
1376 * @param message the actual message
1379 handle_drop (void *cls,
1380 struct GNUNET_SERVER_Client *client,
1381 const struct GNUNET_MessageHeader *message)
1383 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1384 "Processing DROP request\n");
1385 do_drop = GNUNET_YES;
1386 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1391 * Function called by plugins to notify us about a
1392 * change in their disk utilization.
1394 * @param cls closure (NULL)
1395 * @param delta change in disk utilization,
1396 * 0 for "reset to empty"
1399 disk_utilization_change_cb (void *cls,
1402 if ((delta < 0) && (payload < -delta))
1404 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1405 _("Datastore payload must have been inaccurate (%lld < %lld). Recomputing it.\n"),
1406 (long long) payload,
1407 (long long) -delta);
1408 plugin->api->estimate_size (plugin->api->cls,
1410 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1411 _("New payload: %lld\n"),
1412 (long long) payload);
1418 if (last_sync >= MAX_STAT_SYNC_LAG)
1424 * Callback function to process statistic values.
1426 * @param cls closure (struct Plugin*)
1427 * @param subsystem name of subsystem that created the statistic
1428 * @param name the name of the datum
1429 * @param value the current value
1430 * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if not
1431 * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
1434 process_stat_in (void *cls,
1435 const char *subsystem,
1440 GNUNET_assert (GNUNET_NO == stats_worked);
1441 stats_worked = GNUNET_YES;
1443 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1444 "Notification from statistics about existing payload (%llu), new payload is %llu\n",
1445 (unsigned long long) value,
1446 (unsigned long long) payload);
1452 * Load the datastore plugin.
1454 static struct DatastorePlugin *
1457 struct DatastorePlugin *ret;
1460 ret = GNUNET_new (struct DatastorePlugin);
1462 ret->env.duc = &disk_utilization_change_cb;
1463 ret->env.cls = NULL;
1464 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1465 _("Loading `%s' datastore plugin\n"),
1467 GNUNET_asprintf (&libname,
1468 "libgnunet_plugin_datastore_%s",
1470 ret->short_name = GNUNET_strdup (plugin_name);
1471 ret->lib_name = libname;
1472 ret->api = GNUNET_PLUGIN_load (libname, &ret->env);
1473 if (NULL == ret->api)
1475 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1476 _("Failed to load datastore plugin for `%s'\n"),
1478 GNUNET_free (ret->short_name);
1479 GNUNET_free (libname);
1488 * Function called when the service shuts
1489 * down. Unloads our datastore plugin.
1491 * @param plug plugin to unload
1494 unload_plugin (struct DatastorePlugin *plug)
1496 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1497 "Datastore service is unloading plugin...\n");
1498 GNUNET_break (NULL == GNUNET_PLUGIN_unload (plug->lib_name, plug->api));
1499 GNUNET_free (plug->lib_name);
1500 GNUNET_free (plug->short_name);
1505 static const struct GNUNET_SERVER_MessageHandler handlers[] = {
1506 {&handle_reserve, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_RESERVE,
1507 sizeof (struct ReserveMessage)},
1508 {&handle_release_reserve, NULL,
1509 GNUNET_MESSAGE_TYPE_DATASTORE_RELEASE_RESERVE,
1510 sizeof (struct ReleaseReserveMessage)},
1511 {&handle_put, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_PUT, 0},
1512 {&handle_update, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_UPDATE,
1513 sizeof (struct UpdateMessage)},
1514 {&handle_get, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_GET,
1515 sizeof (struct GetMessage) },
1516 {&handle_get_key, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_GET_KEY,
1517 sizeof (struct GetKeyMessage) },
1518 {&handle_get_replication, NULL,
1519 GNUNET_MESSAGE_TYPE_DATASTORE_GET_REPLICATION,
1520 sizeof (struct GNUNET_MessageHeader)},
1521 {&handle_get_zero_anonymity, NULL,
1522 GNUNET_MESSAGE_TYPE_DATASTORE_GET_ZERO_ANONYMITY,
1523 sizeof (struct GetZeroAnonymityMessage)},
1524 {&handle_remove, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_REMOVE, 0},
1525 {&handle_drop, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_DROP,
1526 sizeof (struct GNUNET_MessageHeader)},
1532 * Adds a given @a key to the bloomfilter in @a cls @a count times.
1534 * @param cls the bloomfilter
1535 * @param key key to add
1536 * @param count number of times to add key
1539 add_key_to_bloomfilter (void *cls,
1540 const struct GNUNET_HashCode *key,
1543 struct GNUNET_CONTAINER_BloomFilter *bf = cls;
1547 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1548 _("Bloomfilter construction complete.\n"));
1549 GNUNET_SERVER_add_handlers (server, handlers);
1550 GNUNET_SERVER_resume (server);
1552 = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
1559 GNUNET_CONTAINER_bloomfilter_add (bf, key);
1564 * We finished receiving the statistic. Initialize the plugin; if
1565 * loading the statistic failed, run the estimator.
1568 * @param success #GNUNET_NO if we failed to read the stat
1571 process_stat_done (void *cls,
1575 if (NULL != stat_timeout_task)
1577 GNUNET_SCHEDULER_cancel (stat_timeout_task);
1578 stat_timeout_task = NULL;
1580 plugin = load_plugin ();
1583 GNUNET_CONTAINER_bloomfilter_free (filter);
1587 GNUNET_STATISTICS_destroy (stats, GNUNET_YES);
1592 if (GNUNET_NO == stats_worked)
1594 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1595 "Failed to obtain value from statistics service, recomputing it\n");
1596 plugin->api->estimate_size (plugin->api->cls,
1598 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1599 _("New payload: %lld\n"),
1600 (long long) payload);
1603 if (GNUNET_YES == refresh_bf)
1605 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1606 _("Rebuilding bloomfilter. Please be patient.\n"));
1607 if (NULL != plugin->api->get_keys)
1609 plugin->api->get_keys (plugin->api->cls,
1610 &add_key_to_bloomfilter,
1615 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1616 _("Plugin does not support get_keys function. Please fix!\n"));
1618 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1619 _("Bloomfilter construction complete.\n"));
1622 GNUNET_SERVER_add_handlers (server, handlers);
1623 GNUNET_SERVER_resume (server);
1625 = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
1632 * Fetching stats took to long, run without.
1637 stat_timeout (void *cls)
1639 stat_timeout_task = NULL;
1640 GNUNET_STATISTICS_get_cancel (stat_get);
1641 process_stat_done (NULL, GNUNET_NO);
1646 * Task run during shutdown.
1649 cleaning_task (void *cls)
1651 struct TransmitCallbackContext *tcc;
1653 cleaning_done = GNUNET_YES;
1654 while (NULL != (tcc = tcc_head))
1656 GNUNET_CONTAINER_DLL_remove (tcc_head, tcc_tail, tcc);
1657 if (tcc->th != NULL)
1659 GNUNET_SERVER_notify_transmit_ready_cancel (tcc->th);
1660 GNUNET_SERVER_client_drop (tcc->client);
1662 GNUNET_free (tcc->msg);
1665 if (NULL != expired_kill_task)
1667 GNUNET_SCHEDULER_cancel (expired_kill_task);
1668 expired_kill_task = NULL;
1670 if (GNUNET_YES == do_drop)
1672 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1673 "Dropping database!\n");
1674 plugin->api->drop (plugin->api->cls);
1680 unload_plugin (plugin);
1685 GNUNET_CONTAINER_bloomfilter_free (filter);
1688 if (NULL != stat_get)
1690 GNUNET_STATISTICS_get_cancel (stat_get);
1693 if (NULL != stat_timeout_task)
1695 GNUNET_SCHEDULER_cancel (stat_timeout_task);
1696 stat_timeout_task = NULL;
1698 GNUNET_free_non_null (plugin_name);
1704 GNUNET_STATISTICS_destroy (stats,
1708 GNUNET_free (quota_stat_name);
1709 quota_stat_name = NULL;
1714 * Function that removes all active reservations made
1715 * by the given client and releases the space for other
1718 * @param cls closure
1719 * @param client identification of the client
1722 cleanup_reservations (void *cls,
1723 struct GNUNET_SERVER_Client *client)
1725 struct ReservationList *pos;
1726 struct ReservationList *prev;
1727 struct ReservationList *next;
1736 if (pos->client == client)
1739 reservations = next;
1742 reserved -= pos->amount + pos->entries * GNUNET_DATASTORE_ENTRY_OVERHEAD;
1751 GNUNET_STATISTICS_set (stats,
1752 gettext_noop ("# reserved"),
1759 * Process datastore requests.
1761 * @param cls closure
1762 * @param serv the initialized server
1763 * @param c configuration to use
1767 struct GNUNET_SERVER_Handle *serv,
1768 const struct GNUNET_CONFIGURATION_Handle *c)
1772 unsigned int bf_size;
1777 GNUNET_CONFIGURATION_get_value_string (cfg,
1782 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1783 _("No `%s' specified for `%s' in configuration!\n"),
1788 GNUNET_asprintf ("a_stat_name,
1789 _("# bytes used in file-sharing datastore `%s'"),
1792 GNUNET_CONFIGURATION_get_value_size (cfg, "DATASTORE", "QUOTA", "a))
1794 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1795 _("No `%s' specified for `%s' in configuration!\n"),
1800 stats = GNUNET_STATISTICS_create ("datastore", cfg);
1801 GNUNET_STATISTICS_set (stats, gettext_noop ("# quota"), quota, GNUNET_NO);
1802 cache_size = quota / 8; /* Or should we make this an option? */
1803 GNUNET_STATISTICS_set (stats, gettext_noop ("# cache size"), cache_size,
1805 if (quota / (32 * 1024LL) > (1 << 31))
1806 bf_size = (1 << 31); /* absolute limit: ~2 GB, beyond that BF just won't help anyway */
1808 bf_size = quota / (32 * 1024LL); /* 8 bit per entry, 1 bit per 32 kb in DB */
1811 GNUNET_CONFIGURATION_get_value_filename (cfg,
1815 (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn)))
1817 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1818 _("Could not use specified filename `%s' for bloomfilter.\n"),
1819 NULL != fn ? fn : "");
1820 GNUNET_free_non_null (fn);
1825 GNUNET_asprintf (&pfn, "%s.%s", fn, plugin_name);
1826 if (GNUNET_YES == GNUNET_DISK_file_test (pfn))
1828 filter = GNUNET_CONTAINER_bloomfilter_load (pfn, bf_size, 5); /* approx. 3% false positives at max use */
1831 /* file exists but not valid, remove and try again, but refresh */
1832 if (0 != UNLINK (pfn))
1834 /* failed to remove, run without file */
1835 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1836 _("Failed to remove bogus bloomfilter file `%s'\n"),
1840 filter = GNUNET_CONTAINER_bloomfilter_load (NULL, bf_size, 5); /* approx. 3% false positives at max use */
1841 refresh_bf = GNUNET_YES;
1845 /* try again after remove */
1846 filter = GNUNET_CONTAINER_bloomfilter_load (pfn, bf_size, 5); /* approx. 3% false positives at max use */
1847 refresh_bf = GNUNET_YES;
1850 /* failed yet again, give up on using file */
1851 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1852 _("Failed to remove bogus bloomfilter file `%s'\n"),
1856 filter = GNUNET_CONTAINER_bloomfilter_init (NULL, bf_size, 5); /* approx. 3% false positives at max use */
1862 /* normal case: have an existing valid bf file, no need to refresh */
1863 refresh_bf = GNUNET_NO;
1868 filter = GNUNET_CONTAINER_bloomfilter_load (pfn, bf_size, 5); /* approx. 3% false positives at max use */
1869 refresh_bf = GNUNET_YES;
1875 filter = GNUNET_CONTAINER_bloomfilter_init (NULL, bf_size, 5); /* approx. 3% false positives at max use */
1876 refresh_bf = GNUNET_YES;
1878 GNUNET_free_non_null (fn);
1881 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1882 _("Failed to initialize bloomfilter.\n"));
1885 GNUNET_STATISTICS_destroy (stats, GNUNET_YES);
1890 GNUNET_SERVER_suspend (server);
1892 GNUNET_STATISTICS_get (stats,
1898 if (NULL == stat_get)
1899 process_stat_done (NULL, GNUNET_SYSERR);
1901 stat_timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
1904 GNUNET_SERVER_disconnect_notify (server,
1905 &cleanup_reservations,
1907 GNUNET_SCHEDULER_add_shutdown (&cleaning_task,
1913 * The main function for the datastore service.
1915 * @param argc number of arguments from the command line
1916 * @param argv command line arguments
1917 * @return 0 ok, 1 on error
1927 GNUNET_SERVICE_run (argc, argv, "datastore",
1928 GNUNET_SERVICE_OPTION_NONE,
1929 &run, NULL)) ? 0 : 1;
1934 /* end of gnunet-service-datastore.c */