[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] branch master updated: disconnect CADET only after
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] branch master updated: disconnect CADET only after client count hits zero |
Date: |
Mon, 02 Oct 2017 09:35:05 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new 73f3dbe65 disconnect CADET only after client count hits zero
73f3dbe65 is described below
commit 73f3dbe65643956dd1d872730cdd08c71cd076c5
Author: Christian Grothoff <address@hidden>
AuthorDate: Mon Oct 2 09:36:09 2017 +0200
disconnect CADET only after client count hits zero
---
src/datastore/plugin_datastore_sqlite.c | 18 +-----------------
src/set/gnunet-service-set.c | 32 +++++++++++++++++++++++++++++---
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);
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [gnunet] branch master updated: disconnect CADET only after client count hits zero,
gnunet <=