better clean up
authorChristian Grothoff <christian@grothoff.org>
Fri, 12 Mar 2010 16:16:01 +0000 (16:16 +0000)
committerChristian Grothoff <christian@grothoff.org>
Fri, 12 Mar 2010 16:16:01 +0000 (16:16 +0000)
src/datastore/gnunet-service-datastore.c
src/datastore/plugin_datastore_sqlite.c
src/datastore/test_datastore_api_data.conf

index 1454504e80589b63b13e4edbbb60e64e5f478488..9f5d594b5721b083e024b26ae854d382b314b0b0 100644 (file)
@@ -1263,8 +1263,11 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
                                   tcc_tail,
                                   tcc);
       if (tcc->th != NULL)
-       GNUNET_CONNECTION_notify_transmit_ready_cancel (tcc->th);
-      if (NULL != tcc->tc)
+       {
+         GNUNET_CONNECTION_notify_transmit_ready_cancel (tcc->th);
+         GNUNET_SERVER_client_drop (tcc->client);
+       }
+   if (NULL != tcc->tc)
        tcc->tc (tcc->tc_cls, GNUNET_SYSERR);
       GNUNET_free (tcc->msg);
       GNUNET_free (tcc);
index 78b4533499d6a9eedc632d67341b5a56f705ca02..60c419092ceade57818649ef3d8c2d58d7c26d6a 100644 (file)
@@ -132,6 +132,11 @@ struct Plugin
    */
   struct GNUNET_STATISTICS_GetHandle *stat_get;
 
+  /**
+   * Closure of the 'next_task' (must be freed if 'next_task' is cancelled).
+   */
+  struct NextContext *next_task_nc;
+
   /**
    * Pending task with scheduler for running the next request.
    */
@@ -533,7 +538,7 @@ static void
 sqlite_next_request_cont (void *cls,
                          const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-  struct NextContext * nc= cls;
+  struct NextContext * nc = cls;
   struct Plugin *plugin;
   unsigned long long rowid;
   sqlite3_stmt *stmtd;
@@ -548,6 +553,7 @@ sqlite_next_request_cont (void *cls,
   
   plugin = nc->plugin;
   plugin->next_task = GNUNET_SCHEDULER_NO_TASK;
+  plugin->next_task_nc = NULL;
   if ( (GNUNET_YES == nc->end_it) ||
        (GNUNET_OK != (nc->prep(nc->prep_cls,
                               nc))) )
@@ -673,6 +679,7 @@ sqlite_next_request (void *next_cls,
 
   if (GNUNET_YES == end_it)
     nc->end_it = GNUNET_YES;
+  nc->plugin->next_task_nc = nc;
   nc->plugin->next_task = GNUNET_SCHEDULER_add_now (nc->plugin->env->sched,
                                                    &sqlite_next_request_cont,
                                                    nc);
@@ -1655,6 +1662,9 @@ libgnunet_plugin_datastore_sqlite_done (void *cls)
       GNUNET_SCHEDULER_cancel (plugin->env->sched,
                               plugin->next_task);
       plugin->next_task = GNUNET_SCHEDULER_NO_TASK;
+      plugin->next_task_nc->prep (plugin->next_task_nc->prep_cls, NULL);
+      GNUNET_free (plugin->next_task_nc);
+      plugin->next_task_nc = NULL;
     }
   fn = NULL;
   if (plugin->drop_on_shutdown)
index 32b948c59523deb704b2051a769700c994d4dbe7..6a92a00b3529a81ef6308d12ef7d9b8a707e3424 100644 (file)
@@ -31,6 +31,8 @@ DATABASE = sqlite
 # REJECT_FROM =
 # REJECT_FROM6 =
 # PREFIX =
+#PREFIX = valgrind --tool=memcheck --leak-check=yes
+#BINARY = /home/grothoff/bin/gnunet-service-datastore
 
 [statistics]
 PORT = 22667