gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-exchange] branch master updated (e6bd2a83 -> 85f10a86)


From: gnunet
Subject: [taler-exchange] branch master updated (e6bd2a83 -> 85f10a86)
Date: Mon, 20 Jan 2020 11:15:22 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a change to branch master
in repository exchange.

    from e6bd2a83 properly shut down wirewatch
     new c381a2ab troublesome vars, remove
     new 72293a25 Merge branch 'master' of git+ssh://git.taler.net/exchange
     new 85f10a86 handle case where get_session() is called from main, i.e. in 
combination with -f option

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/exchange/test_taler_exchange_httpd_afl.sh |  4 ++-
 src/exchangedb/plugin_exchangedb_postgres.c   | 42 ++++++++++++++++++++++-----
 2 files changed, 38 insertions(+), 8 deletions(-)

diff --git a/src/exchange/test_taler_exchange_httpd_afl.sh 
b/src/exchange/test_taler_exchange_httpd_afl.sh
index 64884b75..cab70722 100755
--- a/src/exchange/test_taler_exchange_httpd_afl.sh
+++ b/src/exchange/test_taler_exchange_httpd_afl.sh
@@ -32,6 +32,8 @@
 
 set -eu
 
+unset XDG_DATA_HOME
+unset XDG_CONFIG_HOME
 PREFIX=
 # Uncomment this line to run with valgrind...
 PREFIX="valgrind --leak-check=yes --track-fds=yes --error-exitcode=1 
--log-file=valgrind.%p"
@@ -45,6 +47,6 @@ export GNUNET_FORCE_LOG=";;;;ERROR"
 for n in afl-tests/*
 do
   echo -n "Test $n "
-  $PREFIX taler-exchange-httpd -c test_taler_exchange_httpd.conf -t 1 -f $n -C 
> /dev/null && echo "OK" || echo "FAIL $!!"
+  $PREFIX taler-exchange-httpd -c test_taler_exchange_httpd.conf -t 1 -f $n -C 
> /dev/null && echo "OK" || echo "FAIL"
 done
 exit 0
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c 
b/src/exchangedb/plugin_exchangedb_postgres.c
index 9f330cc8..9ccf96b5 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -134,6 +134,16 @@ struct PostgresClosure
    * Which currency should we assume all amounts to be in?
    */
   char *currency;
+
+  /**
+   * Session to be used if the thread is @e main_self.
+   */
+  struct TALER_EXCHANGEDB_Session *main_session;
+
+  /**
+   * Handle for the main() thread of the program.
+   */
+  pthread_t main_self;
 };
 
 
@@ -223,7 +233,12 @@ postgres_get_session (void *cls)
   struct GNUNET_PQ_Context *db_conn;
   struct TALER_EXCHANGEDB_Session *session;
 
-  if (NULL != (session = pthread_getspecific (pc->db_conn_threadlocal)))
+  if (pthread_equal (pc->main_self,
+                     pthread_self ()))
+    session = pc->main_session;
+  else
+    session = pthread_getspecific (pc->db_conn_threadlocal);
+  if (NULL != session)
   {
     GNUNET_PQ_reconnect_if_down (session->conn);
     return session;
@@ -1381,13 +1396,21 @@ postgres_get_session (void *cls)
     return NULL;
   session = GNUNET_new (struct TALER_EXCHANGEDB_Session);
   session->conn = db_conn;
-  if (0 != pthread_setspecific (pc->db_conn_threadlocal,
-                                session))
+  if (pthread_equal (pc->main_self,
+                     pthread_self ()))
   {
-    GNUNET_break (0);
-    GNUNET_PQ_disconnect (db_conn);
-    GNUNET_free (session);
-    return NULL;
+    pc->main_session = session;
+  }
+  else
+  {
+    if (0 != pthread_setspecific (pc->db_conn_threadlocal,
+                                  session))
+    {
+      GNUNET_break (0);
+      GNUNET_PQ_disconnect (db_conn);
+      GNUNET_free (session);
+      return NULL;
+    }
   }
   return session;
 }
@@ -7195,6 +7218,7 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
   const char *ec;
 
   pg = GNUNET_new (struct PostgresClosure);
+  pg->main_self = pthread_self (); /* loaded while single-threaded! */
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_filename (cfg,
                                                "exchangedb-postgres",
@@ -7379,6 +7403,10 @@ libtaler_plugin_exchangedb_postgres_done (void *cls)
   struct TALER_EXCHANGEDB_Plugin *plugin = cls;
   struct PostgresClosure *pg = plugin->cls;
 
+  /* If we launched a session for the main thread,
+     kill it here before we unload */
+  if (NULL != pg->main_session)
+    db_conn_destroy (pg->main_session);
   GNUNET_free (pg->connection_cfg_str);
   GNUNET_free (pg->sql_dir);
   GNUNET_free (pg->currency);

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]