summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/exchange/taler-exchange-httpd.c47
-rw-r--r--src/exchange/taler-exchange-httpd_keystate.c63
-rw-r--r--src/exchange/taler-exchange-httpd_keystate.h4
-rwxr-xr-xsrc/exchange/test_taler_exchange_httpd.sh7
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c3
-rw-r--r--src/mhd/mhd_legal.c5
6 files changed, 69 insertions, 60 deletions
diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c
index c0e91250d..666cec0c1 100644
--- a/src/exchange/taler-exchange-httpd.c
+++ b/src/exchange/taler-exchange-httpd.c
@@ -983,7 +983,7 @@ main (int argc,
char *cfgfile = NULL;
char *loglev = NULL;
char *logfile = NULL;
- int connection_close;
+ int connection_close = GNUNET_NO;
const struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_option_flag ('C',
"connection-close",
@@ -1084,31 +1084,32 @@ main (int argc,
}
/* initialize #internal_key_state with an RC of 1 */
- TEH_KS_init ();
-
- /* consider unix path */
- if ( (-1 == fh) &&
- (NULL != serve_unixpath) )
+ if (GNUNET_OK ==
+ TEH_KS_init ())
{
- fh = TALER_MHD_open_unix_path (serve_unixpath,
- unixpath_mode);
- if (-1 == fh)
- return 1;
- }
#if HAVE_DEVELOPER
- if (NULL != input_filename)
- {
- if (-1 != fh)
- GNUNET_break (0 == close (fh));
- ret = run_single_request ();
- }
- else
+ if (NULL != input_filename)
+ {
+ ret = run_single_request ();
+ }
+ else
#endif
- ret = run_main_loop (fh,
- argv);
-
- /* release #internal_key_state */
- TEH_KS_free ();
+ {
+ /* consider unix path */
+ if ( (-1 == fh) &&
+ (NULL != serve_unixpath) )
+ {
+ fh = TALER_MHD_open_unix_path (serve_unixpath,
+ unixpath_mode);
+ if (-1 == fh)
+ return 1;
+ }
+ ret = run_main_loop (fh,
+ argv);
+ }
+ /* release #internal_key_state */
+ TEH_KS_free ();
+ }
TALER_EXCHANGEDB_plugin_unload (TEH_plugin);
TEH_VALIDATION_done ();
return (GNUNET_SYSERR == ret) ? 1 : 0;
diff --git a/src/exchange/taler-exchange-httpd_keystate.c b/src/exchange/taler-exchange-httpd_keystate.c
index d70c0e7fc..27f22925d 100644
--- a/src/exchange/taler-exchange-httpd_keystate.c
+++ b/src/exchange/taler-exchange-httpd_keystate.c
@@ -2170,30 +2170,8 @@ handle_sigchld ()
int
TEH_KS_loop (void)
{
- struct GNUNET_SIGNAL_Context *sigusr1;
- struct GNUNET_SIGNAL_Context *sigterm;
- struct GNUNET_SIGNAL_Context *sigint;
- struct GNUNET_SIGNAL_Context *sighup;
- struct GNUNET_SIGNAL_Context *sigchld;
int ret;
- if (0 != pipe (reload_pipe))
- {
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
- "pipe");
- return GNUNET_SYSERR;
- }
- sigusr1 = GNUNET_SIGNAL_handler_install (SIGUSR1,
- &handle_sigusr1);
- sigterm = GNUNET_SIGNAL_handler_install (SIGTERM,
- &handle_sigterm);
- sigint = GNUNET_SIGNAL_handler_install (SIGINT,
- &handle_sigint);
- sighup = GNUNET_SIGNAL_handler_install (SIGHUP,
- &handle_sighup);
- sigchld = GNUNET_SIGNAL_handler_install (SIGCHLD,
- &handle_sigchld);
-
ret = 2;
while (2 == ret)
{
@@ -2267,32 +2245,48 @@ TEH_KS_loop (void)
break;
}
}
- GNUNET_SIGNAL_handler_uninstall (sigusr1);
- GNUNET_SIGNAL_handler_uninstall (sigterm);
- GNUNET_SIGNAL_handler_uninstall (sigint);
- GNUNET_SIGNAL_handler_uninstall (sighup);
- GNUNET_SIGNAL_handler_uninstall (sigchld);
- GNUNET_break (0 == close (reload_pipe[0]));
- GNUNET_break (0 == close (reload_pipe[1]));
return ret;
}
+static struct GNUNET_SIGNAL_Context *sigusr1;
+static struct GNUNET_SIGNAL_Context *sigterm;
+static struct GNUNET_SIGNAL_Context *sigint;
+static struct GNUNET_SIGNAL_Context *sighup;
+static struct GNUNET_SIGNAL_Context *sigchld;
+
/**
* Setup initial #internal_key_state.
*/
-void
+int
TEH_KS_init (void)
{
+ if (0 != pipe (reload_pipe))
+ {
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
+ "pipe");
+ return GNUNET_SYSERR;
+ }
+ sigusr1 = GNUNET_SIGNAL_handler_install (SIGUSR1,
+ &handle_sigusr1);
+ sigterm = GNUNET_SIGNAL_handler_install (SIGTERM,
+ &handle_sigterm);
+ sigint = GNUNET_SIGNAL_handler_install (SIGINT,
+ &handle_sigint);
+ sighup = GNUNET_SIGNAL_handler_install (SIGHUP,
+ &handle_sighup);
+ sigchld = GNUNET_SIGNAL_handler_install (SIGCHLD,
+ &handle_sigchld);
/* no need to lock here, as we are still single-threaded */
internal_key_state = make_fresh_key_state (GNUNET_TIME_absolute_get ());
if (NULL == internal_key_state)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to setup initial key state. This exchange cannot work.\n");
- return;
+ return GNUNET_SYSERR;
}
internal_key_state->refcnt = 1;
+ return GNUNET_OK;
}
@@ -2312,6 +2306,13 @@ TEH_KS_free ()
GNUNET_assert (1 == ks->refcnt);
ks->refcnt--;
ks_free (ks);
+ GNUNET_SIGNAL_handler_uninstall (sigusr1);
+ GNUNET_SIGNAL_handler_uninstall (sigterm);
+ GNUNET_SIGNAL_handler_uninstall (sigint);
+ GNUNET_SIGNAL_handler_uninstall (sighup);
+ GNUNET_SIGNAL_handler_uninstall (sigchld);
+ GNUNET_break (0 == close (reload_pipe[0]));
+ GNUNET_break (0 == close (reload_pipe[1]));
}
diff --git a/src/exchange/taler-exchange-httpd_keystate.h b/src/exchange/taler-exchange-httpd_keystate.h
index a7deb94f8..ebcefa08a 100644
--- a/src/exchange/taler-exchange-httpd_keystate.h
+++ b/src/exchange/taler-exchange-httpd_keystate.h
@@ -84,8 +84,10 @@ TEH_KS_release_ (const char *location,
/**
* Setup initial #internal_key_state.
+ *
+ * @return #GNUNET_OK on success
*/
-void
+int
TEH_KS_init (void);
diff --git a/src/exchange/test_taler_exchange_httpd.sh b/src/exchange/test_taler_exchange_httpd.sh
index 6840fa9d4..2ff5830d2 100755
--- a/src/exchange/test_taler_exchange_httpd.sh
+++ b/src/exchange/test_taler_exchange_httpd.sh
@@ -27,7 +27,7 @@ unset XDG_CONFIG_HOME
echo -n "Launching exchange ..."
PREFIX=
# Uncomment this line to run with valgrind...
-#PREFIX="valgrind --leak-check=yes --track-fds=yes --error-exitcode=1 --log-file=valgrind.%p"
+# PREFIX="valgrind --leak-check=yes --track-fds=yes --error-exitcode=1 --log-file=valgrind.%p"
# Setup keys.
taler-exchange-keyup -c test_taler_exchange_httpd.conf || exit 1
@@ -38,7 +38,7 @@ $PREFIX taler-exchange-httpd -c test_taler_exchange_httpd.conf -i 2> test-exchan
# Give HTTP time to start
-for n in `seq 1 20`
+for n in `seq 1 100`
do
echo -n "."
sleep 0.1
@@ -49,6 +49,9 @@ done
if [ 1 != $OK ]
then
echo "Failed to launch exchange"
+ kill -TERM $!
+ wait $!
+ echo Process status: $?
exit 77
fi
echo " DONE"
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
index 9ccf96b54..4d0b1bb6a 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -7405,8 +7405,7 @@ libtaler_plugin_exchangedb_postgres_done (void *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);
+ db_conn_destroy (pg->main_session);
GNUNET_free (pg->connection_cfg_str);
GNUNET_free (pg->sql_dir);
GNUNET_free (pg->currency);
diff --git a/src/mhd/mhd_legal.c b/src/mhd/mhd_legal.c
index fac974127..5af946d8f 100644
--- a/src/mhd/mhd_legal.c
+++ b/src/mhd/mhd_legal.c
@@ -485,7 +485,10 @@ load_language (struct TALER_MHD_Legal *legal,
lang);
d = opendir (dname);
if (NULL == d)
+ {
+ GNUNET_free (dname);
return;
+ }
for (struct dirent *de = readdir (d);
NULL != de;
de = readdir (d))
@@ -497,7 +500,7 @@ load_language (struct TALER_MHD_Legal *legal,
load_terms (legal, path, lang, fn);
}
closedir (d);
- free (dname);
+ GNUNET_free (dname);
}