gnunet-service-datastore.c   gnunet-service-datastore.c 
skipping to change at line 246 skipping to change at line 246
struct TransmitCallbackContext *prev; struct TransmitCallbackContext *prev;
/** /**
* The message that we're asked to transmit. * The message that we're asked to transmit.
*/ */
struct GNUNET_MessageHeader *msg; struct GNUNET_MessageHeader *msg;
/** /**
* Handle for the transmission request. * Handle for the transmission request.
*/ */
struct GNUNET_CONNECTION_TransmitHandle *th; struct GNUNET_SERVER_TransmitHandle *th;
/** /**
* Client that we are transmitting to. * Client that we are transmitting to.
*/ */
struct GNUNET_SERVER_Client *client; struct GNUNET_SERVER_Client *client;
}; };
/** /**
* Head of the doubly-linked list (for cleanup). * Head of the doubly-linked list (for cleanup).
skipping to change at line 334 skipping to change at line 334
now = GNUNET_TIME_absolute_get (); now = GNUNET_TIME_absolute_get ();
if (expiration.abs_value > now.abs_value) if (expiration.abs_value > now.abs_value)
{ {
/* finished processing */ /* finished processing */
expired_kill_task = expired_kill_task =
GNUNET_SCHEDULER_add_delayed_with_priority (MAX_EXPIRE_DELAY, GNUNET_SCHEDULER_add_delayed_with_priority (MAX_EXPIRE_DELAY,
GNUNET_SCHEDULER_PRIORIT Y_IDLE, GNUNET_SCHEDULER_PRIORIT Y_IDLE,
&delete_expired, NULL); &delete_expired, NULL);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Deleting content `%s' of type %u that expired %llu ms ago\n" , "Deleting content `%s' of type %u that expired %llu ms ago\n" ,
GNUNET_h2s (key), type, GNUNET_h2s (key), type,
(unsigned long long) (now.abs_value - expiration.abs_value)); (unsigned long long) (now.abs_value - expiration.abs_value));
#endif
min_expiration = now; min_expiration = now;
GNUNET_STATISTICS_update (stats, gettext_noop ("# bytes expired"), size, GNUNET_STATISTICS_update (stats, gettext_noop ("# bytes expired"), size,
GNUNET_YES); GNUNET_YES);
GNUNET_CONTAINER_bloomfilter_remove (filter, key); GNUNET_CONTAINER_bloomfilter_remove (filter, key);
expired_kill_task = expired_kill_task =
GNUNET_SCHEDULER_add_delayed_with_priority (MIN_EXPIRE_DELAY, GNUNET_SCHEDULER_add_delayed_with_priority (MIN_EXPIRE_DELAY,
GNUNET_SCHEDULER_PRIORITY_ IDLE, GNUNET_SCHEDULER_PRIORITY_ IDLE,
&delete_expired, NULL); &delete_expired, NULL);
return GNUNET_NO; return GNUNET_NO;
} }
skipping to change at line 396 skipping to change at line 394
static int static int
quota_processor (void *cls, const GNUNET_HashCode * key, uint32_t size, quota_processor (void *cls, const GNUNET_HashCode * key, uint32_t size,
const void *data, enum GNUNET_BLOCK_Type type, const void *data, enum GNUNET_BLOCK_Type type,
uint32_t priority, uint32_t anonymity, uint32_t priority, uint32_t anonymity,
struct GNUNET_TIME_Absolute expiration, uint64_t uid) struct GNUNET_TIME_Absolute expiration, uint64_t uid)
{ {
unsigned long long *need = cls; unsigned long long *need = cls;
if (NULL == key) if (NULL == key)
return GNUNET_SYSERR; return GNUNET_SYSERR;
#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Deleting %llu bytes of low-priority (%u) content `%s' of typ e %u at %llu ms prior to expiration (still trying to free another %llu byte s)\n", "Deleting %llu bytes of low-priority (%u) content `%s' of typ e %u at %llu ms prior to expiration (still trying to free another %llu byte s)\n",
(unsigned long long) (size + GNUNET_DATASTORE_ENTRY_OVERHEAD) , (unsigned long long) (size + GNUNET_DATASTORE_ENTRY_OVERHEAD) ,
(unsigned int) priority, (unsigned int) priority,
GNUNET_h2s (key), type, GNUNET_h2s (key), type,
(unsigned long long) GNUNET_TIME_absolute_get_remaining (expir ation).rel_value, (unsigned long long) GNUNET_TIME_absolute_get_remaining (expir ation).rel_value,
*need); *need);
#endif
if (size + GNUNET_DATASTORE_ENTRY_OVERHEAD > *need) if (size + GNUNET_DATASTORE_ENTRY_OVERHEAD > *need)
*need = 0; *need = 0;
else else
*need -= size + GNUNET_DATASTORE_ENTRY_OVERHEAD; *need -= size + GNUNET_DATASTORE_ENTRY_OVERHEAD;
if (priority > 0) if (priority > 0)
min_expiration = GNUNET_TIME_UNIT_FOREVER_ABS; min_expiration = GNUNET_TIME_UNIT_FOREVER_ABS;
else else
min_expiration = expiration; min_expiration = expiration;
GNUNET_STATISTICS_update (stats, GNUNET_STATISTICS_update (stats,
gettext_noop ("# bytes purged (low-priority)"), gettext_noop ("# bytes purged (low-priority)"),
skipping to change at line 437 skipping to change at line 433
* *
* @param need number of bytes of content that were * @param need number of bytes of content that were
* placed into the "cache" (and hence the * placed into the "cache" (and hence the
* number of bytes that should be removed). * number of bytes that should be removed).
*/ */
static void static void
manage_space (unsigned long long need) manage_space (unsigned long long need)
{ {
unsigned long long last; unsigned long long last;
#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Asked to free up %llu bytes of cache space\n", need); "Asked to free up %llu bytes of cache space\n", need);
#endif
last = 0; last = 0;
while ((need > 0) && (last != need)) while ((need > 0) && (last != need))
{ {
last = need; last = need;
plugin->api->get_expiration (plugin->api->cls, &quota_processor, &need) ; plugin->api->get_expiration (plugin->api->cls, &quota_processor, &need) ;
} }
} }
/** /**
* Function called to notify a client about the socket * Function called to notify a client about the socket
skipping to change at line 501 skipping to change at line 495
* @param client target of the message * @param client target of the message
* @param msg message to transmit, will be freed! * @param msg message to transmit, will be freed!
*/ */
static void static void
transmit (struct GNUNET_SERVER_Client *client, struct GNUNET_MessageHeader *msg) transmit (struct GNUNET_SERVER_Client *client, struct GNUNET_MessageHeader *msg)
{ {
struct TransmitCallbackContext *tcc; struct TransmitCallbackContext *tcc;
if (GNUNET_YES == cleaning_done) if (GNUNET_YES == cleaning_done)
{ {
#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Shutdown in progress, aborting transmission.\n"); _("Shutdown in progress, aborting transmission.\n"));
#endif
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
GNUNET_free (msg); GNUNET_free (msg);
return; return;
} }
tcc = GNUNET_malloc (sizeof (struct TransmitCallbackContext)); tcc = GNUNET_malloc (sizeof (struct TransmitCallbackContext));
tcc->msg = msg; tcc->msg = msg;
tcc->client = client; tcc->client = client;
if (NULL == if (NULL ==
(tcc->th = (tcc->th =
GNUNET_SERVER_notify_transmit_ready (client, ntohs (msg->size), GNUNET_SERVER_notify_transmit_ready (client, ntohs (msg->size),
skipping to change at line 541 skipping to change at line 533
* @param client receiver of the response * @param client receiver of the response
* @param code status code * @param code status code
* @param msg optional error message (can be NULL) * @param msg optional error message (can be NULL)
*/ */
static void static void
transmit_status (struct GNUNET_SERVER_Client *client, int code, const char *msg) transmit_status (struct GNUNET_SERVER_Client *client, int code, const char *msg)
{ {
struct StatusMessage *sm; struct StatusMessage *sm;
size_t slen; size_t slen;
#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Transmitting `%s' message with value %d and message `%s'\n", "Transmitting `%s' message with value %d and message `%s'\n",
"STATUS", code, msg != NULL ? msg : "(none)"); "STATUS", code, msg != NULL ? msg : "(none)");
#endif
slen = (msg == NULL) ? 0 : strlen (msg) + 1; slen = (msg == NULL) ? 0 : strlen (msg) + 1;
sm = GNUNET_malloc (sizeof (struct StatusMessage) + slen); sm = GNUNET_malloc (sizeof (struct StatusMessage) + slen);
sm->header.size = htons (sizeof (struct StatusMessage) + slen); sm->header.size = htons (sizeof (struct StatusMessage) + slen);
sm->header.type = htons (GNUNET_MESSAGE_TYPE_DATASTORE_STATUS); sm->header.type = htons (GNUNET_MESSAGE_TYPE_DATASTORE_STATUS);
sm->status = htonl (code); sm->status = htonl (code);
sm->min_expiration = GNUNET_TIME_absolute_hton (min_expiration); sm->min_expiration = GNUNET_TIME_absolute_hton (min_expiration);
if (slen > 0) if (slen > 0)
memcpy (&sm[1], msg, slen); memcpy (&sm[1], msg, slen);
transmit (client, &sm->header); transmit (client, &sm->header);
} }
skipping to change at line 588 skipping to change at line 578
uint32_t anonymity, struct GNUNET_TIME_Absolute expiration, uint32_t anonymity, struct GNUNET_TIME_Absolute expiration,
uint64_t uid) uint64_t uid)
{ {
struct GNUNET_SERVER_Client *client = cls; struct GNUNET_SERVER_Client *client = cls;
struct GNUNET_MessageHeader *end; struct GNUNET_MessageHeader *end;
struct DataMessage *dm; struct DataMessage *dm;
if (key == NULL) if (key == NULL)
{ {
/* transmit 'DATA_END' */ /* transmit 'DATA_END' */
#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting `%s' message\n", GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting `%s' message\n",
"DATA_END"); "DATA_END");
#endif
end = GNUNET_malloc (sizeof (struct GNUNET_MessageHeader)); end = GNUNET_malloc (sizeof (struct GNUNET_MessageHeader));
end->size = htons (sizeof (struct GNUNET_MessageHeader)); end->size = htons (sizeof (struct GNUNET_MessageHeader));
end->type = htons (GNUNET_MESSAGE_TYPE_DATASTORE_DATA_END); end->type = htons (GNUNET_MESSAGE_TYPE_DATASTORE_DATA_END);
transmit (client, end); transmit (client, end);
GNUNET_SERVER_client_drop (client); GNUNET_SERVER_client_drop (client);
return GNUNET_OK; return GNUNET_OK;
} }
GNUNET_assert (sizeof (struct DataMessage) + size < GNUNET_assert (sizeof (struct DataMessage) + size <
GNUNET_SERVER_MAX_MESSAGE_SIZE); GNUNET_SERVER_MAX_MESSAGE_SIZE);
dm = GNUNET_malloc (sizeof (struct DataMessage) + size); dm = GNUNET_malloc (sizeof (struct DataMessage) + size);
skipping to change at line 615 skipping to change at line 603
dm->size = htonl (size); dm->size = htonl (size);
dm->type = htonl (type); dm->type = htonl (type);
dm->priority = htonl (priority); dm->priority = htonl (priority);
dm->anonymity = htonl (anonymity); dm->anonymity = htonl (anonymity);
dm->replication = htonl (0); dm->replication = htonl (0);
dm->reserved = htonl (0); dm->reserved = htonl (0);
dm->expiration = GNUNET_TIME_absolute_hton (expiration); dm->expiration = GNUNET_TIME_absolute_hton (expiration);
dm->uid = GNUNET_htonll (uid); dm->uid = GNUNET_htonll (uid);
dm->key = *key; dm->key = *key;
memcpy (&dm[1], data, size); memcpy (&dm[1], data, size);
#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Transmitting `%s' message for `%s' of type %u with expiratio n %llu (now: %llu)\n", "Transmitting `%s' message for `%s' of type %u with expiratio n %llu (now: %llu)\n",
"DATA", GNUNET_h2s (key), type, "DATA", GNUNET_h2s (key), type,
(unsigned long long) expiration.abs_value, (unsigned long long) expiration.abs_value,
(unsigned long long) GNUNET_TIME_absolute_get ().abs_value); (unsigned long long) GNUNET_TIME_absolute_get ().abs_value);
#endif
GNUNET_STATISTICS_update (stats, gettext_noop ("# results found"), 1, GNUNET_STATISTICS_update (stats, gettext_noop ("# results found"), 1,
GNUNET_NO); GNUNET_NO);
transmit (client, &dm->header); transmit (client, &dm->header);
GNUNET_SERVER_client_drop (client); GNUNET_SERVER_client_drop (client);
return GNUNET_OK; return GNUNET_OK;
} }
/** /**
* Handle RESERVE-message. * Handle RESERVE-message.
* *
skipping to change at line 652 skipping to change at line 638
*/ */
static int reservation_gen; static int reservation_gen;
const struct ReserveMessage *msg = (const struct ReserveMessage *) messag e; const struct ReserveMessage *msg = (const struct ReserveMessage *) messag e;
struct ReservationList *e; struct ReservationList *e;
unsigned long long used; unsigned long long used;
unsigned long long req; unsigned long long req;
uint64_t amount; uint64_t amount;
uint32_t entries; uint32_t entries;
#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' request\n", "RESERV E"); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' request\n", "RESERV E");
#endif
amount = GNUNET_ntohll (msg->amount); amount = GNUNET_ntohll (msg->amount);
entries = ntohl (msg->entries); entries = ntohl (msg->entries);
used = payload + reserved; used = payload + reserved;
req = req =
amount + ((unsigned long long) GNUNET_DATASTORE_ENTRY_OVERHEAD) * ent ries; amount + ((unsigned long long) GNUNET_DATASTORE_ENTRY_OVERHEAD) * ent ries;
if (used + req > quota) if (used + req > quota)
{ {
if (quota < used) if (quota < used)
used = quota; /* cheat a bit for error message (to avoid negative numbers) */ used = quota; /* cheat a bit for error message (to avoid negative numbers) */
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
skipping to change at line 725 skipping to change at line 709
const struct GNUNET_MessageHeader *message) const struct GNUNET_MessageHeader *message)
{ {
const struct ReleaseReserveMessage *msg = const struct ReleaseReserveMessage *msg =
(const struct ReleaseReserveMessage *) message; (const struct ReleaseReserveMessage *) message;
struct ReservationList *pos; struct ReservationList *pos;
struct ReservationList *prev; struct ReservationList *prev;
struct ReservationList *next; struct ReservationList *next;
int rid = ntohl (msg->rid); int rid = ntohl (msg->rid);
unsigned long long rem; unsigned long long rem;
#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' request\n", GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' request\n",
"RELEASE_RESERVE"); "RELEASE_RESERVE");
#endif
next = reservations; next = reservations;
prev = NULL; prev = NULL;
while (NULL != (pos = next)) while (NULL != (pos = next))
{ {
next = pos->next; next = pos->next;
if (rid == pos->rid) if (rid == pos->rid)
{ {
if (prev == NULL) if (prev == NULL)
reservations = next; reservations = next;
else else
prev->next = next; prev->next = next;
rem = rem =
pos->amount + pos->amount +
((unsigned long long) GNUNET_DATASTORE_ENTRY_OVERHEAD) * pos->ent ries; ((unsigned long long) GNUNET_DATASTORE_ENTRY_OVERHEAD) * pos->ent ries;
GNUNET_assert (reserved >= rem); GNUNET_assert (reserved >= rem);
reserved -= rem; reserved -= rem;
GNUNET_STATISTICS_set (stats, gettext_noop ("# reserved"), reserved, GNUNET_STATISTICS_set (stats, gettext_noop ("# reserved"), reserved,
GNUNET_NO); GNUNET_NO);
#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Returning %llu remaining reserved bytes to storage pool\ n", "Returning %llu remaining reserved bytes to storage pool\ n",
rem); rem);
#endif
GNUNET_free (pos); GNUNET_free (pos);
transmit_status (client, GNUNET_OK, NULL); transmit_status (client, GNUNET_OK, NULL);
return; return;
} }
prev = pos; prev = pos;
} }
GNUNET_break (0); GNUNET_break (0);
transmit_status (client, GNUNET_SYSERR, transmit_status (client, GNUNET_SYSERR,
gettext_noop ("Could not find matching reservation")); gettext_noop ("Could not find matching reservation"));
} }
skipping to change at line 834 skipping to change at line 814
ret = ret =
plugin->api->put (plugin->api->cls, &dm->key, size, &dm[1], plugin->api->put (plugin->api->cls, &dm->key, size, &dm[1],
ntohl (dm->type), ntohl (dm->priority), ntohl (dm->type), ntohl (dm->priority),
ntohl (dm->anonymity), ntohl (dm->replication), ntohl (dm->anonymity), ntohl (dm->replication),
GNUNET_TIME_absolute_ntoh (dm->expiration), &msg); GNUNET_TIME_absolute_ntoh (dm->expiration), &msg);
if (GNUNET_OK == ret) if (GNUNET_OK == ret)
{ {
GNUNET_STATISTICS_update (stats, gettext_noop ("# bytes stored"), size, GNUNET_STATISTICS_update (stats, gettext_noop ("# bytes stored"), size,
GNUNET_YES); GNUNET_YES);
GNUNET_CONTAINER_bloomfilter_add (filter, &dm->key); GNUNET_CONTAINER_bloomfilter_add (filter, &dm->key);
#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Successfully stored %u bytes of type %u under key `%s'\n", "Successfully stored %u bytes of type %u under key `%s'\n",
size, ntohl (dm->type), GNUNET_h2s (&dm->key)); size, ntohl (dm->type), GNUNET_h2s (&dm->key));
#endif
} }
transmit_status (client, ret, msg); transmit_status (client, ret, msg);
GNUNET_free_non_null (msg); GNUNET_free_non_null (msg);
if (quota - reserved - cache_size < payload) if (quota - reserved - cache_size < payload)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
_("Need %llu bytes more space (%llu allowed, using %llu)\n" ), _("Need %llu bytes more space (%llu allowed, using %llu)\n" ),
(unsigned long long) size + GNUNET_DATASTORE_ENTRY_OVERHEAD , (unsigned long long) size + GNUNET_DATASTORE_ENTRY_OVERHEAD ,
(unsigned long long) (quota - reserved - cache_size), (unsigned long long) (quota - reserved - cache_size),
(unsigned long long) payload); (unsigned long long) payload);
skipping to change at line 893 skipping to change at line 871
execute_put (pc->client, dm); execute_put (pc->client, dm);
GNUNET_SERVER_client_drop (pc->client); GNUNET_SERVER_client_drop (pc->client);
GNUNET_free (pc); GNUNET_free (pc);
return GNUNET_OK; return GNUNET_OK;
} }
if ((GNUNET_BLOCK_TYPE_FS_DBLOCK == type) || if ((GNUNET_BLOCK_TYPE_FS_DBLOCK == type) ||
(GNUNET_BLOCK_TYPE_FS_IBLOCK == type) || ((size == ntohl (dm->size)) && (GNUNET_BLOCK_TYPE_FS_IBLOCK == type) || ((size == ntohl (dm->size)) &&
(0 == (0 ==
memcmp (&dm[1], data, size )))) memcmp (&dm[1], data, size ))))
{ {
#if DEBUG_MYSQL
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Result already present in datastore\n"); "Result already present in datastore\n");
#endif
/* FIXME: change API to allow increasing 'replication' counter */ /* FIXME: change API to allow increasing 'replication' counter */
if ((ntohl (dm->priority) > 0) || if ((ntohl (dm->priority) > 0) ||
(GNUNET_TIME_absolute_ntoh (dm->expiration).abs_value > (GNUNET_TIME_absolute_ntoh (dm->expiration).abs_value >
expiration.abs_value)) expiration.abs_value))
plugin->api->update (plugin->api->cls, uid, plugin->api->update (plugin->api->cls, uid,
(int32_t) ntohl (dm->priority), (int32_t) ntohl (dm->priority),
GNUNET_TIME_absolute_ntoh (dm->expiration), NULL ); GNUNET_TIME_absolute_ntoh (dm->expiration), NULL );
transmit_status (pc->client, GNUNET_NO, NULL); transmit_status (pc->client, GNUNET_NO, NULL);
GNUNET_SERVER_client_drop (pc->client); GNUNET_SERVER_client_drop (pc->client);
GNUNET_free (pc); GNUNET_free (pc);
skipping to change at line 941 skipping to change at line 917
struct PutContext *pc; struct PutContext *pc;
GNUNET_HashCode vhash; GNUNET_HashCode vhash;
uint32_t size; uint32_t size;
if ((dm == NULL) || (ntohl (dm->type) == 0)) if ((dm == NULL) || (ntohl (dm->type) == 0))
{ {
GNUNET_break (0); GNUNET_break (0);
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return; return;
} }
#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Processing `%s' request for `%s' of type %u\n", "PUT", "Processing `%s' request for `%s' of type %u\n", "PUT",
GNUNET_h2s (&dm->key), ntohl (dm->type)); GNUNET_h2s (&dm->key), ntohl (dm->type));
#endif
rid = ntohl (dm->rid); rid = ntohl (dm->rid);
size = ntohl (dm->size); size = ntohl (dm->size);
if (rid > 0) if (rid > 0)
{ {
pos = reservations; pos = reservations;
while ((NULL != pos) && (rid != pos->rid)) while ((NULL != pos) && (rid != pos->rid))
pos = pos->next; pos = pos->next;
GNUNET_break (pos != NULL); GNUNET_break (pos != NULL);
if (NULL != pos) if (NULL != pos)
{ {
skipping to change at line 1003 skipping to change at line 977
size = ntohs (message->size); size = ntohs (message->size);
if ((size != sizeof (struct GetMessage)) && if ((size != sizeof (struct GetMessage)) &&
(size != sizeof (struct GetMessage) - sizeof (GNUNET_HashCode))) (size != sizeof (struct GetMessage) - sizeof (GNUNET_HashCode)))
{ {
GNUNET_break (0); GNUNET_break (0);
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return; return;
} }
msg = (const struct GetMessage *) message; msg = (const struct GetMessage *) message;
#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Processing `%s' request for `%s' of type %u\n", "GET", "Processing `%s' request for `%s' of type %u\n", "GET",
GNUNET_h2s (&msg->key), ntohl (msg->type)); GNUNET_h2s (&msg->key), ntohl (msg->type));
#endif
GNUNET_STATISTICS_update (stats, gettext_noop ("# GET requests received") , 1, GNUNET_STATISTICS_update (stats, gettext_noop ("# GET requests received") , 1,
GNUNET_NO); GNUNET_NO);
GNUNET_SERVER_client_keep (client); GNUNET_SERVER_client_keep (client);
if ((size == sizeof (struct GetMessage)) && if ((size == sizeof (struct GetMessage)) &&
(GNUNET_YES != GNUNET_CONTAINER_bloomfilter_test (filter, &msg->key)) ) (GNUNET_YES != GNUNET_CONTAINER_bloomfilter_test (filter, &msg->key)) )
{ {
/* don't bother database... */ /* don't bother database... */
#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Empty result set for `%s' request for `%s' (bloomfilter).\ n", "Empty result set for `%s' request for `%s' (bloomfilter).\ n",
"GET", GNUNET_h2s (&msg->key)); "GET", GNUNET_h2s (&msg->key));
#endif
GNUNET_STATISTICS_update (stats, GNUNET_STATISTICS_update (stats,
gettext_noop gettext_noop
("# requests filtered by bloomfilter"), 1, ("# requests filtered by bloomfilter"), 1,
GNUNET_NO); GNUNET_NO);
transmit_item (client, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_AB S, transmit_item (client, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_AB S,
0); 0);
return; return;
} }
plugin->api->get_key (plugin->api->cls, GNUNET_ntohll (msg->offset), plugin->api->get_key (plugin->api->cls, GNUNET_ntohll (msg->offset),
((size == ((size ==
skipping to change at line 1053 skipping to change at line 1023
const struct GNUNET_MessageHeader *message) const struct GNUNET_MessageHeader *message)
{ {
const struct UpdateMessage *msg; const struct UpdateMessage *msg;
int ret; int ret;
char *emsg; char *emsg;
GNUNET_STATISTICS_update (stats, gettext_noop ("# UPDATE requests receive d"), GNUNET_STATISTICS_update (stats, gettext_noop ("# UPDATE requests receive d"),
1, GNUNET_NO); 1, GNUNET_NO);
msg = (const struct UpdateMessage *) message; msg = (const struct UpdateMessage *) message;
emsg = NULL; emsg = NULL;
#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' request for %llu\n" , GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' request for %llu\n" ,
"UPDATE", (unsigned long long) GNUNET_ntohll (msg->uid)); "UPDATE", (unsigned long long) GNUNET_ntohll (msg->uid));
#endif
ret = ret =
plugin->api->update (plugin->api->cls, GNUNET_ntohll (msg->uid), plugin->api->update (plugin->api->cls, GNUNET_ntohll (msg->uid),
(int32_t) ntohl (msg->priority), (int32_t) ntohl (msg->priority),
GNUNET_TIME_absolute_ntoh (msg->expiration), &em sg); GNUNET_TIME_absolute_ntoh (msg->expiration), &em sg);
transmit_status (client, ret, emsg); transmit_status (client, ret, emsg);
GNUNET_free_non_null (emsg); GNUNET_free_non_null (emsg);
} }
/** /**
* Handle GET_REPLICATION-message. * Handle GET_REPLICATION-message.
* *
* @param cls closure * @param cls closure
* @param client identification of the client * @param client identification of the client
* @param message the actual message * @param message the actual message
*/ */
static void static void
handle_get_replication (void *cls, struct GNUNET_SERVER_Client *client, handle_get_replication (void *cls, struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message) const struct GNUNET_MessageHeader *message)
{ {
#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' request\n", GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' request\n",
"GET_REPLICATION"); "GET_REPLICATION");
#endif
GNUNET_STATISTICS_update (stats, GNUNET_STATISTICS_update (stats,
gettext_noop gettext_noop
("# GET REPLICATION requests received"), 1, ("# GET REPLICATION requests received"), 1,
GNUNET_NO); GNUNET_NO);
GNUNET_SERVER_client_keep (client); GNUNET_SERVER_client_keep (client);
plugin->api->get_replication (plugin->api->cls, &transmit_item, client); plugin->api->get_replication (plugin->api->cls, &transmit_item, client);
} }
/** /**
* Handle GET_ZERO_ANONYMITY-message. * Handle GET_ZERO_ANONYMITY-message.
skipping to change at line 1110 skipping to change at line 1076
(const struct GetZeroAnonymityMessage *) message; (const struct GetZeroAnonymityMessage *) message;
enum GNUNET_BLOCK_Type type; enum GNUNET_BLOCK_Type type;
type = (enum GNUNET_BLOCK_Type) ntohl (msg->type); type = (enum GNUNET_BLOCK_Type) ntohl (msg->type);
if (type == GNUNET_BLOCK_TYPE_ANY) if (type == GNUNET_BLOCK_TYPE_ANY)
{ {
GNUNET_break (0); GNUNET_break (0);
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return; return;
} }
#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' request\n", GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' request\n",
"GET_ZERO_ANONYMITY"); "GET_ZERO_ANONYMITY");
#endif
GNUNET_STATISTICS_update (stats, GNUNET_STATISTICS_update (stats,
gettext_noop gettext_noop
("# GET ZERO ANONYMITY requests received"), 1, ("# GET ZERO ANONYMITY requests received"), 1,
GNUNET_NO); GNUNET_NO);
GNUNET_SERVER_client_keep (client); GNUNET_SERVER_client_keep (client);
plugin->api->get_zero_anonymity (plugin->api->cls, plugin->api->get_zero_anonymity (plugin->api->cls,
GNUNET_ntohll (msg->offset), type, GNUNET_ntohll (msg->offset), type,
&transmit_item, client); &transmit_item, client);
} }
skipping to change at line 1138 skipping to change at line 1102
static int static int
remove_callback (void *cls, const GNUNET_HashCode * key, uint32_t size, remove_callback (void *cls, const GNUNET_HashCode * key, uint32_t size,
const void *data, enum GNUNET_BLOCK_Type type, const void *data, enum GNUNET_BLOCK_Type type,
uint32_t priority, uint32_t anonymity, uint32_t priority, uint32_t anonymity,
struct GNUNET_TIME_Absolute expiration, uint64_t uid) struct GNUNET_TIME_Absolute expiration, uint64_t uid)
{ {
struct GNUNET_SERVER_Client *client = cls; struct GNUNET_SERVER_Client *client = cls;
if (key == NULL) if (key == NULL)
{ {
#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"No further matches for `%s' request.\n", "REMOVE"); "No further matches for `%s' request.\n", "REMOVE");
#endif
transmit_status (client, GNUNET_NO, _("Content not found")); transmit_status (client, GNUNET_NO, _("Content not found"));
GNUNET_SERVER_client_drop (client); GNUNET_SERVER_client_drop (client);
return GNUNET_OK; /* last item */ return GNUNET_OK; /* last item */
} }
#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Item %llu matches `%s' request for key `%s' and type %u.\n", "Item %llu matches `%s' request for key `%s' and type %u.\n",
(unsigned long long) uid, "REMOVE", GNUNET_h2s (key), type); (unsigned long long) uid, "REMOVE", GNUNET_h2s (key), type);
#endif
GNUNET_STATISTICS_update (stats, GNUNET_STATISTICS_update (stats,
gettext_noop ("# bytes removed (explicit reques t)"), gettext_noop ("# bytes removed (explicit reques t)"),
size, GNUNET_YES); size, GNUNET_YES);
GNUNET_CONTAINER_bloomfilter_remove (filter, key); GNUNET_CONTAINER_bloomfilter_remove (filter, key);
transmit_status (client, GNUNET_OK, NULL); transmit_status (client, GNUNET_OK, NULL);
GNUNET_SERVER_client_drop (client); GNUNET_SERVER_client_drop (client);
return GNUNET_NO; return GNUNET_NO;
} }
/** /**
skipping to change at line 1180 skipping to change at line 1140
{ {
const struct DataMessage *dm = check_data (message); const struct DataMessage *dm = check_data (message);
GNUNET_HashCode vhash; GNUNET_HashCode vhash;
if (dm == NULL) if (dm == NULL)
{ {
GNUNET_break (0); GNUNET_break (0);
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return; return;
} }
#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Processing `%s' request for `%s' of type %u\n", "REMOVE", "Processing `%s' request for `%s' of type %u\n", "REMOVE",
GNUNET_h2s (&dm->key), ntohl (dm->type)); GNUNET_h2s (&dm->key), ntohl (dm->type));
#endif
GNUNET_STATISTICS_update (stats, gettext_noop ("# REMOVE requests receive d"), GNUNET_STATISTICS_update (stats, gettext_noop ("# REMOVE requests receive d"),
1, GNUNET_NO); 1, GNUNET_NO);
GNUNET_SERVER_client_keep (client); GNUNET_SERVER_client_keep (client);
GNUNET_CRYPTO_hash (&dm[1], ntohl (dm->size), &vhash); GNUNET_CRYPTO_hash (&dm[1], ntohl (dm->size), &vhash);
plugin->api->get_key (plugin->api->cls, 0, &dm->key, &vhash, plugin->api->get_key (plugin->api->cls, 0, &dm->key, &vhash,
(enum GNUNET_BLOCK_Type) ntohl (dm->type), (enum GNUNET_BLOCK_Type) ntohl (dm->type),
&remove_callback, client); &remove_callback, client);
} }
/** /**
* Handle DROP-message. * Handle DROP-message.
* *
* @param cls closure * @param cls closure
* @param client identification of the client * @param client identification of the client
* @param message the actual message * @param message the actual message
*/ */
static void static void
handle_drop (void *cls, struct GNUNET_SERVER_Client *client, handle_drop (void *cls, struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message) const struct GNUNET_MessageHeader *message)
{ {
#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' request\n", "DROP") ; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' request\n", "DROP") ;
#endif
do_drop = GNUNET_YES; do_drop = GNUNET_YES;
GNUNET_SERVER_receive_done (client, GNUNET_OK); GNUNET_SERVER_receive_done (client, GNUNET_OK);
} }
/** /**
* Function called by plugins to notify us about a * Function called by plugins to notify us about a
* change in their disk utilization. * change in their disk utilization.
* *
* @param cls closure (NULL) * @param cls closure (NULL)
* @param delta change in disk utilization, * @param delta change in disk utilization,
skipping to change at line 1256 skipping to change at line 1212
* @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not
* @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
*/ */
static int static int
process_stat_in (void *cls, const char *subsystem, const char *name, process_stat_in (void *cls, const char *subsystem, const char *name,
uint64_t value, int is_persistent) uint64_t value, int is_persistent)
{ {
GNUNET_assert (stats_worked == GNUNET_NO); GNUNET_assert (stats_worked == GNUNET_NO);
stats_worked = GNUNET_YES; stats_worked = GNUNET_YES;
payload += value; payload += value;
#if DEBUG_SQLITE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Notification from statistics about existing payload (%llu), new payload is %llu\n", "Notification from statistics about existing payload (%llu), new payload is %llu\n",
abs_value, payload); value, payload);
#endif
return GNUNET_OK; return GNUNET_OK;
} }
static void static void
process_stat_done (void *cls, int success) process_stat_done (void *cls, int success)
{ {
struct DatastorePlugin *plugin = cls; struct DatastorePlugin *plugin = cls;
stat_get = NULL; stat_get = NULL;
if (stats_worked == GNUNET_NO) if (stats_worked == GNUNET_NO)
skipping to change at line 1314 skipping to change at line 1268
/** /**
* Function called when the service shuts * Function called when the service shuts
* down. Unloads our datastore plugin. * down. Unloads our datastore plugin.
* *
* @param plug plugin to unload * @param plug plugin to unload
*/ */
static void static void
unload_plugin (struct DatastorePlugin *plug) unload_plugin (struct DatastorePlugin *plug)
{ {
#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Datastore service is unloading plugin...\n"); "Datastore service is unloading plugin...\n");
#endif
GNUNET_break (NULL == GNUNET_PLUGIN_unload (plug->lib_name, plug->api)); GNUNET_break (NULL == GNUNET_PLUGIN_unload (plug->lib_name, plug->api));
GNUNET_free (plug->lib_name); GNUNET_free (plug->lib_name);
GNUNET_free (plug->short_name); GNUNET_free (plug->short_name);
GNUNET_free (plug); GNUNET_free (plug);
GNUNET_free (quota_stat_name); GNUNET_free (quota_stat_name);
quota_stat_name = NULL; quota_stat_name = NULL;
} }
/** /**
* Final task run after shutdown. Unloads plugins and disconnects us from * Final task run after shutdown. Unloads plugins and disconnects us from
skipping to change at line 1373 skipping to change at line 1325
cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{ {
struct TransmitCallbackContext *tcc; struct TransmitCallbackContext *tcc;
cleaning_done = GNUNET_YES; cleaning_done = GNUNET_YES;
while (NULL != (tcc = tcc_head)) while (NULL != (tcc = tcc_head))
{ {
GNUNET_CONTAINER_DLL_remove (tcc_head, tcc_tail, tcc); GNUNET_CONTAINER_DLL_remove (tcc_head, tcc_tail, tcc);
if (tcc->th != NULL) if (tcc->th != NULL)
{ {
GNUNET_CONNECTION_notify_transmit_ready_cancel (tcc->th); GNUNET_SERVER_notify_transmit_ready_cancel (tcc->th);
GNUNET_SERVER_client_drop (tcc->client); GNUNET_SERVER_client_drop (tcc->client);
} }
GNUNET_free (tcc->msg); GNUNET_free (tcc->msg);
GNUNET_free (tcc); GNUNET_free (tcc);
} }
if (expired_kill_task != GNUNET_SCHEDULER_NO_TASK) if (expired_kill_task != GNUNET_SCHEDULER_NO_TASK)
{ {
GNUNET_SCHEDULER_cancel (expired_kill_task); GNUNET_SCHEDULER_cancel (expired_kill_task);
expired_kill_task = GNUNET_SCHEDULER_NO_TASK; expired_kill_task = GNUNET_SCHEDULER_NO_TASK;
} }
 End of changes. 50 change blocks. 
52 lines changed or deleted 4 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/