}
}
h->response_proc = NULL;
+#if VERBOSE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received status %d/%s\n",
+ status,
+ emsg);
+#endif
cont (h->response_proc_cls,
status,
emsg);
}
GNUNET_assert (h->message_size <= size);
memcpy (buf, &h[1], h->message_size);
+#if VERBOSE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Transmitted %u byte message to datastore service, now waiting for status.\n",
+ h->message_size);
+#endif
h->message_size = 0;
GNUNET_CLIENT_receive (h->client,
&with_status_response_handler,
hdr = (const struct GNUNET_MessageHeader*) &h[1];
msize = ntohs(hdr->size);
+#if VERBOSE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Transmitting %u byte message of type %u to datastore service\n",
+ msize,
+ ntohs(hdr->type));
+#endif
GNUNET_assert (h->response_proc == NULL);
h->response_proc = cont;
h->response_proc_cls = cont_cls;
{
GNUNET_break (ntohs(msg->size) == sizeof(struct GNUNET_MessageHeader));
h->response_proc = NULL;
+#if VERBOSE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received end of result set\n");
+#endif
cont (h->response_proc_cls,
NULL, 0, NULL, 0, 0, 0, zero, 0);
return;
NULL, 0, NULL, 0, 0, 0, zero, 0);
return;
}
+#if VERBOSE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received result %llu with type %u and size %u with key %s\n",
+ (unsigned long long) GNUNET_ntohll(dm->uid),
+ ntohl(dm->type),
+ msize,
+ GNUNET_h2s(&dm->key));
+#endif
cont (h->response_proc_cls,
&dm->key,
msize,
}
GNUNET_assert (h->message_size <= size);
memcpy (buf, &h[1], h->message_size);
+#if VERBOSE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Transmitted %u byte message to datastore service, now waiting for result.\n",
+ h->message_size);
+#endif
h->message_size = 0;
GNUNET_CLIENT_receive (h->client,
&with_result_response_handler,
hdr = (const struct GNUNET_MessageHeader*) &h[1];
msize = ntohs(hdr->size);
+#if VERBOSE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Transmitting %u byte message of type %u to datastore service\n",
+ msize,
+ ntohs(hdr->type));
+#endif
GNUNET_assert (h->response_proc == NULL);
h->response_proc = cont;
h->response_proc_cls = cont_cls;
#include "plugin_datastore.h"
#include "datastore.h"
+#define DEBUG_DATASTORE GNUNET_YES
+
/**
* How many messages do we queue at most per client?
*/
msize = ntohs(tcc->msg->size);
if (size == 0)
{
+#if DEBUG_DATASTORE
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Transmission failed.\n");
+#endif
if (tcc->tc != NULL)
tcc->tc (tcc->tc_cls, GNUNET_SYSERR);
if (GNUNET_YES == tcc->end)
- GNUNET_SERVER_receive_done (tcc->client, GNUNET_SYSERR);
+ {
+#if DEBUG_DATASTORE
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Disconnecting client.\n");
+#endif
+ GNUNET_SERVER_receive_done (tcc->client, GNUNET_SYSERR);
+ }
GNUNET_free (tcc->msg);
GNUNET_free (tcc);
return 0;
if (tcc->tc != NULL)
tcc->tc (tcc->tc_cls, GNUNET_OK);
if (GNUNET_YES == tcc->end)
- GNUNET_SERVER_receive_done (tcc->client, GNUNET_OK);
+ {
+#if DEBUG_DATASTORE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Request completed, ready for the next request!\n");
+#endif
+ GNUNET_SERVER_receive_done (tcc->client, GNUNET_OK);
+ }
+ else
+ {
+#if DEBUG_DATASTORE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Response transmitted, more pending!\n");
+#endif
+ }
GNUNET_free (tcc->msg);
GNUNET_free (tcc);
return msize;
{
GNUNET_break (0);
if (GNUNET_YES == end)
- GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ {
+#if DEBUG_DATASTORE
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Disconnecting client.\n");
+#endif
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ }
if (NULL != tc)
tc (tc_cls, GNUNET_SYSERR);
GNUNET_free (msg);
struct StatusMessage *sm;
size_t slen;
+#if DEBUG_DATASTORE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Transmitting `s' message with value %d and message %s\n",
+ "STATUS",
+ code,
+ msg);
+#endif
slen = (msg == NULL) ? 0 : strlen(msg) + 1;
sm = GNUNET_malloc (sizeof(struct StatusMessage) + slen);
sm->header.size = htons(sizeof(struct StatusMessage) + slen);
if (key == NULL)
{
/* transmit 'DATA_END' */
+#if DEBUG_DATASTORE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Transmitting `%s' message\n",
+ "DATA_END");
+#endif
end = GNUNET_malloc (sizeof(struct GNUNET_MessageHeader));
end->size = htons(sizeof(struct GNUNET_MessageHeader));
end->type = htons(GNUNET_MESSAGE_TYPE_DATASTORE_DATA_END);
dm->uid = GNUNET_htonll(uid);
dm->key = *key;
memcpy (&dm[1], data, size);
+#if DEBUG_DATASTORE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Transmitting `%s' message\n",
+ "DATA");
+#endif
transmit (client, &dm->header, &get_next, next_cls, GNUNET_NO);
return GNUNET_OK;
}
const struct ReserveMessage *msg = (const struct ReserveMessage*) message;
struct ReservationList *e;
- /* FIXME: check if we have that much space... */
+#if DEBUG_DATASTORE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Processing `%s' request\n",
+ "RESERVE");
+#endif
+ /* FIXME: check if we have that much space... */
e = GNUNET_malloc (sizeof(struct ReservationList));
e->next = reservations;
reservations = e;
struct ReservationList *pos;
struct ReservationList *prev;
struct ReservationList *next;
-
int rid = ntohl(msg->rid);
+
+#if DEBUG_DATASTORE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Processing `%s' request\n",
+ "RELEASE_RESERVE");
+#endif
next = reservations;
prev = NULL;
while (NULL != (pos = next))
int ret;
int rid;
+#if DEBUG_DATASTORE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Processing `%s' request\n",
+ "PUT");
+#endif
if (dm == NULL)
{
GNUNET_break (0);
const struct GetMessage *msg;
uint16_t size;
+#if DEBUG_DATASTORE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Processing `%s' request\n",
+ "GET");
+#endif
size = ntohs(message->size);
if ( (size != sizeof(struct GetMessage)) &&
(size != sizeof(struct GetMessage) - sizeof(GNUNET_HashCode)) )
int ret;
char *emsg;
+#if DEBUG_DATASTORE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Processing `%s' request\n",
+ "UPDATE");
+#endif
msg = (const struct UpdateMessage*) message;
emsg = NULL;
ret = plugin->api->update (plugin->api->cls,
struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
- GNUNET_SERVER_client_drop (client);
+#if DEBUG_DATASTORE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Processing `%s' request\n",
+ "GET_RANDOM");
+#endif
+ GNUNET_SERVER_client_drop (client); // FIXME: WTF?
plugin->api->iter_migration_order (plugin->api->cls,
0,
&transmit_item,
GNUNET_HashCode vhash;
struct RemoveContext *rc;
+#if DEBUG_DATASTORE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Processing `%s' request\n",
+ "REMOVE");
+#endif
if (dm == NULL)
{
GNUNET_break (0);
struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
+#if DEBUG_DATASTORE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Processing `%s' request\n",
+ "DROP");
+#endif
plugin->api->drop (plugin->api->cls);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
#include "gnunet_protocols.h"
#include "gnunet_datastore_service.h"
+#define VERBOSE GNUNET_YES
+
/**
* How long until we give up on transmitting the message?
*/
#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15)
+#define ITERATIONS 256
+
static struct GNUNET_DATASTORE_Handle *datastore;
static struct GNUNET_TIME_Absolute now;
switch (crc->phase)
{
case RP_PUT:
- memset (&crc->key, 256 - crc->i, sizeof (GNUNET_HashCode));
+#if VERBOSE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Executing `%s' number %u\n",
+ "PUT",
+ crc->i);
+#endif
+ memset (&crc->key, ITERATIONS - crc->i, sizeof (GNUNET_HashCode));
GNUNET_DATASTORE_put (datastore,
0,
&crc->key,
&check_success,
crc);
crc->i++;
- if (crc->i == 256)
+ if (crc->i == ITERATIONS)
crc->phase = RP_GET;
break;
case RP_GET:
crc->i--;
- memset (&crc->key, 256 - crc->i, sizeof (GNUNET_HashCode));
+#if VERBOSE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Executing `%s' number %u\n",
+ "GET",
+ crc->i);
+#endif
+ memset (&crc->key, ITERATIONS - crc->i, sizeof (GNUNET_HashCode));
GNUNET_DATASTORE_get (datastore,
&crc->key,
get_type (crc->i),
if (crc->i == 0)
{
crc->phase = RP_DEL;
- crc->i = 256;
+ crc->i = ITERATIONS;
}
break;
case RP_DEL:
crc->i--;
- memset (&crc->key, 256 - crc->i, sizeof (GNUNET_HashCode));
+#if VERBOSE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Executing `%s' number %u\n",
+ "DEL",
+ crc->i);
+#endif
+ memset (&crc->key, ITERATIONS - crc->i, sizeof (GNUNET_HashCode));
GNUNET_DATASTORE_get (datastore,
&crc->key,
get_type (crc->i),
if (crc->i == 0)
{
crc->phase = RP_DELVALIDATE;
- crc->i = 256;
+ crc->i = ITERATIONS;
}
break;
case RP_DELVALIDATE:
crc->i--;
- memset (&crc->key, 256 - crc->i, sizeof (GNUNET_HashCode));
+#if VERBOSE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Executing `%s' number %u\n",
+ "DEL-VALIDATE",
+ crc->i);
+#endif
+ memset (&crc->key, ITERATIONS - crc->i, sizeof (GNUNET_HashCode));
GNUNET_DATASTORE_get (datastore,
&crc->key,
get_type (crc->i),
/* check update */
/* test multiple results */
case RP_DONE:
+#if VERBOSE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Finished, disconnecting\n");
+#endif
GNUNET_DATASTORE_disconnect (datastore, GNUNET_YES);
ok = 0;
}