}
}
h->response_proc = NULL;
-#if VERBOSE
+#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received status %d/%s\n",
status,
gettext_noop ("Error transmitting message to datastore service.\n"));
return 0;
}
- GNUNET_assert (h->message_size <= size);
- memcpy (buf, &h[1], h->message_size);
-#if VERBOSE
+ msize = h->message_size;
+ GNUNET_assert (msize <= size);
+ memcpy (buf, &h[1], msize);
+#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Transmitted %u byte message to datastore service, now waiting for status.\n",
- h->message_size);
+ msize);
#endif
h->message_size = 0;
GNUNET_CLIENT_receive (h->client,
hdr = (const struct GNUNET_MessageHeader*) &h[1];
msize = ntohs(hdr->size);
-#if VERBOSE
+#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Transmitting %u byte message of type %u to datastore service\n",
msize,
struct DataMessage *dm;
size_t msize;
+#if DEBUG_DATASTORE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Asked to put %u bytes of data\n",
+ size);
+#endif
msize = sizeof(struct DataMessage) + size;
GNUNET_assert (msize <= GNUNET_SERVER_MAX_MESSAGE_SIZE);
dm = (struct DataMessage*) &h[1];
{
GNUNET_break (ntohs(msg->size) == sizeof(struct GNUNET_MessageHeader));
h->response_proc = NULL;
-#if VERBOSE
+#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received end of result set\n");
#endif
NULL, 0, NULL, 0, 0, 0, zero, 0);
return;
}
-#if VERBOSE
+#if DEBUG_DATASTORE
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),
gettext_noop ("Error transmitting message to datastore service.\n"));
return 0;
}
- GNUNET_assert (h->message_size <= size);
- memcpy (buf, &h[1], h->message_size);
-#if VERBOSE
+ msize = h->message_size;
+ GNUNET_assert (msize <= size);
+ memcpy (buf, &h[1], msize);
+#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Transmitted %u byte message to datastore service, now waiting for result.\n",
- h->message_size);
+ msize);
#endif
h->message_size = 0;
GNUNET_CLIENT_receive (h->client,
hdr = (const struct GNUNET_MessageHeader*) &h[1];
msize = ntohs(hdr->size);
-#if VERBOSE
+#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Transmitting %u byte message of type %u to datastore service\n",
msize,
#include "plugin_datastore.h"
#include "datastore.h"
-#define DEBUG_DATASTORE GNUNET_YES
-
/**
* How many messages do we queue at most per client?
*/
tcc->tc (tcc->tc_cls, GNUNET_SYSERR);
if (GNUNET_YES == tcc->end)
{
-#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);
#if DEBUG_DATASTORE
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);
+ msg != NULL ? msg : "(none)");
#endif
slen = (msg == NULL) ? 0 : strlen(msg) + 1;
sm = GNUNET_malloc (sizeof(struct StatusMessage) + slen);
GNUNET_CONTAINER_bloomfilter_add (filter,
&dm->key);
transmit_status (client,
- GNUNET_SYSERR == ret ? GNUNET_SYSERR : GNUNET_OK,
+ (GNUNET_SYSERR == ret) ? GNUNET_SYSERR : GNUNET_OK,
msg);
GNUNET_free_non_null (msg);
}
&msg->key)) )
{
/* don't bother database... */
+#if DEBUG_DATASTORE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Empty result set for `%s' request.\n",
+ "GET");
+#endif
transmit_item (client,
NULL, NULL, 0, NULL, 0, 0, 0, zero, 0);
return;
}
- GNUNET_SERVER_client_drop (client);
+ GNUNET_SERVER_client_keep (client);
plugin->api->get (plugin->api->cls,
((size == sizeof(struct GetMessage)) ? &msg->key : NULL),
NULL,
"Processing `%s' request\n",
"GET_RANDOM");
#endif
- GNUNET_SERVER_client_drop (client); // FIXME: WTF?
+ GNUNET_SERVER_client_keep (client);
plugin->api->iter_migration_order (plugin->api->cls,
0,
&transmit_item,
expiration, uint64_t uid)
{
struct RemoveContext *rc = cls;
+
if (key == NULL)
{
+#if DEBUG_DATASTORE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "No further matches for `%s' request.\n",
+ "REMOVE");
+#endif
if (GNUNET_YES == rc->found)
transmit_status (rc->client, GNUNET_OK, NULL);
else
return GNUNET_OK; /* last item */
}
rc->found = GNUNET_YES;
- plugin->api->next_request (next_cls, GNUNET_YES);
+#if DEBUG_DATASTORE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Item %llu matches `%s' request.\n",
+ (unsigned long long) uid,
+ "REMOVE");
+#endif
GNUNET_CONTAINER_bloomfilter_remove (filter,
key);
+ plugin->api->next_request (next_cls, GNUNET_YES);
return GNUNET_NO;
}
GNUNET_CRYPTO_hash (&dm[1],
ntohl(dm->size),
&vhash);
+ GNUNET_SERVER_client_keep (client);
plugin->api->get (plugin->api->cls,
&dm->key,
&vhash,
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
_("Loading `%s' datastore plugin\n"), name);
GNUNET_asprintf (&libname, "libgnunet_plugin_datastore_%s", name);
- ret->short_name = GNUNET_strdup (name);
+ ret->short_name = name;
ret->lib_name = libname;
ret->api = GNUNET_PLUGIN_load (libname, &ret->env);
if (ret->api == NULL)
#include "plugin_datastore.h"
#include <sqlite3.h>
-#define DEBUG_SQLITE GNUNET_NO
+#define DEBUG_SQLITE GNUNET_YES
/**
* After how many payload-changing operations
#define QUOTA_STAT_NAME gettext_noop ("file-sharing datastore utilization (in bytes)")
-
-/**
- * Die with an error message that indicates
- * a failure of the command 'cmd' with the message given
- * by strerror(errno).
- */
-#define DIE_SQLITE(db, cmd) do { GNUNET_log_from(GNUNET_ERROR_TYPE_ERROR, "sqlite", _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, sqlite3_errmsg(db->dbh)); abort(); } while(0)
-
/**
* Log an error message at log-level 'level' that indicates
* a failure of the command 'cmd' on file 'filename'