summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/datastore/plugin_datastore_sqlite.c18
-rw-r--r--src/set/gnunet-service-set.c32
2 files changed, 30 insertions, 20 deletions
diff --git a/src/datastore/plugin_datastore_sqlite.c b/src/datastore/plugin_datastore_sqlite.c
index 2d539cb19..cc56f5959 100644
--- a/src/datastore/plugin_datastore_sqlite.c
+++ b/src/datastore/plugin_datastore_sqlite.c
@@ -355,40 +355,24 @@ database_setup (const struct GNUNET_CONFIGURATION_Handle *cfg,
(SQLITE_OK !=
sq_prepare (plugin->dbh,
"SELECT " RESULT_COLUMNS " FROM gn091 "
-#if SQLITE_VERSION_NUMBER >= 3007000
- "INDEXED BY idx_repl_rvalue "
-#endif
"WHERE repl=?2 AND " " (rvalue>=?1 OR "
" NOT EXISTS (SELECT 1 FROM gn091 "
-#if SQLITE_VERSION_NUMBER >= 3007000
- "INDEXED BY idx_repl_rvalue "
-#endif
"WHERE repl=?2 AND rvalue>=?1 LIMIT 1) ) "
"ORDER BY rvalue ASC LIMIT 1",
&plugin->selRepl)) ||
(SQLITE_OK !=
sq_prepare (plugin->dbh,
- "SELECT MAX(repl) FROM gn091"
-#if SQLITE_VERSION_NUMBER >= 3007000
- " INDEXED BY idx_repl_rvalue"
-#endif
- "",
+ "SELECT MAX(repl) FROM gn091",
&plugin->maxRepl)) ||
(SQLITE_OK !=
sq_prepare (plugin->dbh,
"SELECT " RESULT_COLUMNS " FROM gn091 "
-#if SQLITE_VERSION_NUMBER >= 3007000
- "INDEXED BY idx_expire "
-#endif
"WHERE NOT EXISTS (SELECT 1 FROM gn091 WHERE expire < ?1 LIMIT 1) OR (expire < ?1) "
"ORDER BY expire ASC LIMIT 1",
&plugin->selExpi)) ||
(SQLITE_OK !=
sq_prepare (plugin->dbh,
"SELECT " RESULT_COLUMNS " FROM gn091 "
-#if SQLITE_VERSION_NUMBER >= 3007000
- "INDEXED BY idx_anon_type "
-#endif
"WHERE _ROWID_ >= ? AND "
"anonLevel = 0 AND "
"type = ? "
diff --git a/src/set/gnunet-service-set.c b/src/set/gnunet-service-set.c
index f98d43a7d..056f70f32 100644
--- a/src/set/gnunet-service-set.c
+++ b/src/set/gnunet-service-set.c
@@ -155,6 +155,17 @@ static struct Listener *listener_head;
static struct Listener *listener_tail;
/**
+ * Number of active clients.
+ */
+static unsigned int num_clients;
+
+/**
+ * Are we in shutdown? if #GNUNET_YES and the number of clients
+ * drops to zero, disconnect from CADET.
+ */
+static int in_shutdown;
+
+/**
* Counter for allocating unique IDs for clients, used to identify
* incoming operation requests from remote peers, that the client can
* choose to accept or refuse. 0 must not be used (reserved for
@@ -485,6 +496,7 @@ client_connect_cb (void *cls,
{
struct ClientState *cs;
+ num_clients++;
cs = GNUNET_new (struct ClientState);
cs->client = c;
cs->mq = mq;
@@ -623,6 +635,16 @@ client_disconnect_cb (void *cls,
GNUNET_free (listener);
}
GNUNET_free (cs);
+ num_clients--;
+ if ( (GNUNET_YES == in_shutdown) &&
+ (0 == num_clients) )
+ {
+ if (NULL != cadet)
+ {
+ GNUNET_CADET_disconnect (cadet);
+ cadet = NULL;
+ }
+ }
}
@@ -1917,10 +1939,14 @@ static void
shutdown_task (void *cls)
{
/* Delay actual shutdown to allow service to disconnect clients */
- if (NULL != cadet)
+ in_shutdown = GNUNET_YES;
+ if (0 == num_clients)
{
- GNUNET_CADET_disconnect (cadet);
- cadet = NULL;
+ if (NULL != cadet)
+ {
+ GNUNET_CADET_disconnect (cadet);
+ cadet = NULL;
+ }
}
GNUNET_STATISTICS_destroy (_GSS_statistics,
GNUNET_YES);