From: Christian Grothoff Date: Mon, 22 Feb 2010 10:48:44 +0000 (+0000) Subject: fix cleanup X-Git-Tag: initial-import-from-subversion-38251~22645 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=391ab060f50b3c705c021c1cd0f73caffd7ef538;p=oweals%2Fgnunet.git fix cleanup --- diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c index 8a3510946..d519bcea5 100644 --- a/src/datastore/gnunet-service-datastore.c +++ b/src/datastore/gnunet-service-datastore.c @@ -930,6 +930,7 @@ handle_get (void *cls, GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); return; } + GNUNET_SERVER_client_keep (client); msg = (const struct GetMessage*) message; if ( (size == sizeof(struct GetMessage)) && (GNUNET_YES != GNUNET_CONTAINER_bloomfilter_test (filter, @@ -942,13 +943,11 @@ handle_get (void *cls, "GET", GNUNET_h2s (&msg->key)); #endif - GNUNET_SERVER_client_keep (client); transmit_item (client, NULL, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); return; } - GNUNET_SERVER_client_keep (client); plugin->api->get (plugin->api->cls, ((size == sizeof(struct GetMessage)) ? &msg->key : NULL), NULL, @@ -1236,6 +1235,20 @@ unload_plugin (struct DatastorePlugin *plug) static void cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { + struct TransmitCallbackContext *tcc; + + while (NULL != (tcc = tcc_head)) + { + GNUNET_CONTAINER_DLL_remove (tcc_head, + tcc_tail, + tcc); + if (tcc->th != NULL) + GNUNET_CONNECTION_notify_transmit_ready_cancel (tcc->th); + if (NULL != tcc->tc) + tcc->tc (tcc->tc_cls, GNUNET_SYSERR); + GNUNET_free (tcc->msg); + GNUNET_free (tcc); + } if (expired_kill_task != GNUNET_SCHEDULER_NO_TASK) { GNUNET_SCHEDULER_cancel (sched, @@ -1295,36 +1308,6 @@ cleanup_reservations (void *cls, } -/** - * Function that removes all active reservations made - * by the given client and releases the space for other - * requests. - * - * @param cls closure - * @param client identification of the client - */ -static void -cleanup_transmits (void *cls, - struct GNUNET_SERVER_Client - * client) -{ - struct TransmitCallbackContext *tcc; - - while (NULL != (tcc = tcc_head)) - { - GNUNET_CONTAINER_DLL_remove (tcc_head, - tcc_tail, - tcc); - if (tcc->th != NULL) - GNUNET_CONNECTION_notify_transmit_ready_cancel (tcc->th); - GNUNET_free (tcc->msg); - GNUNET_free (tcc); - } - -} - - - /** * Process datastore requests. * @@ -1389,7 +1372,6 @@ run (void *cls, return; } GNUNET_SERVER_disconnect_notify (server, &cleanup_reservations, NULL); - GNUNET_SERVER_disconnect_notify (server, &cleanup_transmits, NULL); GNUNET_SERVER_add_handlers (server, handlers); expired_kill_task = GNUNET_SCHEDULER_add_with_priority (sched, diff --git a/src/datastore/plugin_datastore_sqlite.c b/src/datastore/plugin_datastore_sqlite.c index 1607ba5e0..2fc28e13e 100644 --- a/src/datastore/plugin_datastore_sqlite.c +++ b/src/datastore/plugin_datastore_sqlite.c @@ -1427,7 +1427,7 @@ sqlite_plugin_get (void *cls, sqlite_plugin_iter_low_priority (cls, type, iter, iter_cls); return; } - GNUNET_snprintf (scratch, 256, + GNUNET_snprintf (scratch, sizeof (scratch), "SELECT count(*) FROM gn080 WHERE hash=:1%s%s", vhash == NULL ? "" : " AND vhash=:2", type == 0 ? "" : (vhash == @@ -1479,7 +1479,7 @@ sqlite_plugin_get (void *cls, return; } - GNUNET_snprintf (scratch, 256, + GNUNET_snprintf (scratch, sizeof (scratch), "SELECT size, type, prio, anonLevel, expire, hash, value, _ROWID_ " "FROM gn080 WHERE hash=:1%s%s AND _ROWID_ >= :%d " "ORDER BY _ROWID_ ASC LIMIT 1 OFFSET :d",