From: Christian Grothoff Date: Sun, 19 Jul 2009 11:31:54 +0000 (+0000) Subject: bugfixes X-Git-Tag: initial-import-from-subversion-38251~23647 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=1e879063d6c677c3cb0f57bbc61b8d908aeb2a05;p=oweals%2Fgnunet.git bugfixes --- diff --git a/src/datastore/datastore.h b/src/datastore/datastore.h index 45dc70047..7d8e683f5 100644 --- a/src/datastore/datastore.h +++ b/src/datastore/datastore.h @@ -27,6 +27,8 @@ #ifndef DATASTORE_H #define DATASTORE_H +#define DEBUG_DATASTORE GNUNET_YES + #include "gnunet_util_lib.h" /** diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c index 4fc719629..6f02e6fea 100644 --- a/src/datastore/datastore_api.c +++ b/src/datastore/datastore_api.c @@ -215,7 +215,7 @@ with_status_response_handler (void *cls, } } h->response_proc = NULL; -#if VERBOSE +#if DEBUG_DATASTORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received status %d/%s\n", status, @@ -255,12 +255,13 @@ transmit_get_status (void *cls, 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, @@ -295,7 +296,7 @@ transmit_for_status (struct GNUNET_DATASTORE_Handle *h, 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, @@ -356,6 +357,11 @@ GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h, 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]; @@ -502,7 +508,7 @@ with_result_response_handler (void *cls, { 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 @@ -533,7 +539,7 @@ with_result_response_handler (void *cls, 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), @@ -585,12 +591,13 @@ transmit_get_result (void *cls, 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, @@ -626,7 +633,7 @@ transmit_for_result (struct GNUNET_DATASTORE_Handle *h, 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, diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c index 70d349693..74196dd1e 100644 --- a/src/datastore/gnunet-service-datastore.c +++ b/src/datastore/gnunet-service-datastore.c @@ -38,8 +38,6 @@ #include "plugin_datastore.h" #include "datastore.h" -#define DEBUG_DATASTORE GNUNET_YES - /** * How many messages do we queue at most per client? */ @@ -207,10 +205,6 @@ transmit_callback (void *cls, 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); @@ -308,10 +302,10 @@ transmit_status (struct GNUNET_SERVER_Client *client, #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); @@ -578,7 +572,7 @@ handle_put (void *cls, 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); } @@ -619,11 +613,16 @@ handle_get (void *cls, &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, @@ -683,7 +682,7 @@ handle_get_random (void *cls, "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, @@ -725,8 +724,14 @@ remove_callback (void *cls, 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 @@ -736,9 +741,15 @@ remove_callback (void *cls, 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; } @@ -776,6 +787,7 @@ handle_remove (void *cls, GNUNET_CRYPTO_hash (&dm[1], ntohl(dm->size), &vhash); + GNUNET_SERVER_client_keep (client); plugin->api->get (plugin->api->cls, &dm->key, &vhash, @@ -857,7 +869,7 @@ load_plugin (struct GNUNET_CONFIGURATION_Handle *cfg, 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) diff --git a/src/datastore/plugin_datastore_sqlite.c b/src/datastore/plugin_datastore_sqlite.c index 99f940317..ce92d3882 100644 --- a/src/datastore/plugin_datastore_sqlite.c +++ b/src/datastore/plugin_datastore_sqlite.c @@ -29,7 +29,7 @@ #include "plugin_datastore.h" #include -#define DEBUG_SQLITE GNUNET_NO +#define DEBUG_SQLITE GNUNET_YES /** * After how many payload-changing operations @@ -39,14 +39,6 @@ #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' diff --git a/src/datastore/test_datastore_api.c b/src/datastore/test_datastore_api.c index e9545bbf1..56cf0e588 100644 --- a/src/datastore/test_datastore_api.c +++ b/src/datastore/test_datastore_api.c @@ -68,7 +68,7 @@ get_data (int i) static int get_type(int i) { - return i; + return i+1; }