diff options
Diffstat (limited to 'src/mint')
-rw-r--r-- | src/mint/taler-mint-httpd.c | 10 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd.h | 5 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd_keystate.c | 23 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd_mhd.c | 2 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd_responses.c | 19 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd_responses.h | 10 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd_wire.c | 3 |
7 files changed, 72 insertions, 0 deletions
diff --git a/src/mint/taler-mint-httpd.c b/src/mint/taler-mint-httpd.c index 86d20fdba..55ecd58d2 100644 --- a/src/mint/taler-mint-httpd.c +++ b/src/mint/taler-mint-httpd.c @@ -45,6 +45,11 @@ char *TMH_mint_currency_string; /** + * Should we return "Connection: close" in each response? + */ +int TMH_mint_connection_close; + +/** * Base directory of the mint (global) */ char *TMH_mint_directory; @@ -543,11 +548,13 @@ run_fake_client () "nc", "localhost", ports, + "-w", "30", NULL)) && (0 != execlp ("ncat", "ncat", "localhost", ports, + "-i", "30", NULL)) ) { fprintf (stderr, @@ -614,6 +621,9 @@ main (int argc, char *const *argv) { static const struct GNUNET_GETOPT_CommandLineOption options[] = { + {'C', "connection-close", NULL, + "force HTTP connections to be closed after each request", 0, + &GNUNET_GETOPT_set_one, &TMH_mint_connection_close}, {'d', "mint-dir", "DIR", "mint directory with configuration and keys for operating the mint", 1, &GNUNET_GETOPT_set_filename, &TMH_mint_directory}, diff --git a/src/mint/taler-mint-httpd.h b/src/mint/taler-mint-httpd.h index 3cbbc0dfd..e83dd66f2 100644 --- a/src/mint/taler-mint-httpd.h +++ b/src/mint/taler-mint-httpd.h @@ -33,6 +33,11 @@ extern char *TMH_mint_currency_string; /** + * Should we return "Connection: close" in each response? + */ +extern int TMH_mint_connection_close; + +/** * The mint's configuration. */ extern struct GNUNET_CONFIGURATION_Handle *cfg; diff --git a/src/mint/taler-mint-httpd_keystate.c b/src/mint/taler-mint-httpd_keystate.c index 939d57d03..6a0bad540 100644 --- a/src/mint/taler-mint-httpd_keystate.c +++ b/src/mint/taler-mint-httpd_keystate.c @@ -23,6 +23,7 @@ #include "platform.h" #include <pthread.h> #include "taler-mint-httpd_keystate.h" +#include "taler-mint-httpd_responses.h" #include "taler_mintdb_plugin.h" @@ -814,6 +815,17 @@ handle_sighup () /** + * Call #handle_signal() to pass the received signal via + * the control pipe. + */ +static void +handle_sigchld () +{ + handle_signal (SIGCHLD); +} + + +/** * Read signals from a pipe in a loop, and reload keys from disk if * SIGUSR1 is received, terminate if SIGTERM/SIGINT is received, and * restart if SIGHUP is received. @@ -829,6 +841,7 @@ TMH_KS_loop (void) 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)) @@ -845,6 +858,8 @@ TMH_KS_loop (void) &handle_sigint); sighup = GNUNET_SIGNAL_handler_install (SIGHUP, &handle_sighup); + sigchld = GNUNET_SIGNAL_handler_install (SIGCHLD, + &handle_sigchld); ret = 0; while (0 == ret) @@ -890,6 +905,12 @@ read_again: /* restart updated binary */ ret = GNUNET_NO; break; +#if HAVE_DEVELOPER + case SIGCHLD: + /* running in test-mode, test finished, terminate */ + ret = GNUNET_OK; + break; +#endif default: /* unexpected character */ GNUNET_break (0); @@ -905,6 +926,7 @@ read_again: GNUNET_SIGNAL_handler_uninstall (sigterm); GNUNET_SIGNAL_handler_uninstall (sigint); GNUNET_SIGNAL_handler_uninstall (sighup); + GNUNET_SIGNAL_handler_uninstall (sigchld); return ret; } @@ -966,6 +988,7 @@ TMH_KS_handler_keys (struct TMH_RequestHandler *rh, GNUNET_break (0); return MHD_NO; } + TMH_RESPONSE_add_global_headers (response); (void) MHD_add_response_header (response, "Content-Type", rh->mime_type); diff --git a/src/mint/taler-mint-httpd_mhd.c b/src/mint/taler-mint-httpd_mhd.c index b4e3c1f60..419c4fb04 100644 --- a/src/mint/taler-mint-httpd_mhd.c +++ b/src/mint/taler-mint-httpd_mhd.c @@ -65,6 +65,7 @@ TMH_MHD_handler_static_response (struct TMH_RequestHandler *rh, GNUNET_break (0); return MHD_NO; } + TMH_RESPONSE_add_global_headers (response); if (NULL != rh->mime_type) (void) MHD_add_response_header (response, MHD_HTTP_HEADER_CONTENT_TYPE, @@ -108,6 +109,7 @@ TMH_MHD_handler_agpl_redirect (struct TMH_RequestHandler *rh, GNUNET_break (0); return MHD_NO; } + TMH_RESPONSE_add_global_headers (response); if (NULL != rh->mime_type) (void) MHD_add_response_header (response, MHD_HTTP_HEADER_CONTENT_TYPE, diff --git a/src/mint/taler-mint-httpd_responses.c b/src/mint/taler-mint-httpd_responses.c index 367b1904e..50a0553e6 100644 --- a/src/mint/taler-mint-httpd_responses.c +++ b/src/mint/taler-mint-httpd_responses.c @@ -30,6 +30,23 @@ /** + * Add headers we want to return in every response. + * Useful for testing, like if we want to always close + * connections. + * + * @param response response to modify + */ +void +TMH_RESPONSE_add_global_headers (struct MHD_Response *response) +{ + if (TMH_mint_connection_close) + (void) MHD_add_response_header (response, + MHD_HTTP_HEADER_CONNECTION, + "close"); +} + + +/** * Send JSON object as response. * * @param connection the MHD connection @@ -56,6 +73,7 @@ TMH_RESPONSE_reply_json (struct MHD_Connection *connection, GNUNET_break (0); return MHD_NO; } + TMH_RESPONSE_add_global_headers (resp); (void) MHD_add_response_header (resp, MHD_HTTP_HEADER_CONTENT_TYPE, "application/json"); @@ -292,6 +310,7 @@ TMH_RESPONSE_reply_request_too_large (struct MHD_Connection *connection) MHD_RESPMEM_PERSISTENT); if (NULL == resp) return MHD_NO; + TMH_RESPONSE_add_global_headers (resp); ret = MHD_queue_response (connection, MHD_HTTP_REQUEST_ENTITY_TOO_LARGE, resp); diff --git a/src/mint/taler-mint-httpd_responses.h b/src/mint/taler-mint-httpd_responses.h index deb7dd639..9746ef90b 100644 --- a/src/mint/taler-mint-httpd_responses.h +++ b/src/mint/taler-mint-httpd_responses.h @@ -32,6 +32,16 @@ #include "taler-mint-httpd.h" #include "taler-mint-httpd_db.h" +/** + * Add headers we want to return in every response. + * Useful for testing, like if we want to always close + * connections. + * + * @param response response to modify + */ +void +TMH_RESPONSE_add_global_headers (struct MHD_Response *response); + /** * Send JSON object as response. diff --git a/src/mint/taler-mint-httpd_wire.c b/src/mint/taler-mint-httpd_wire.c index 143d7c48d..9c00b5d43 100644 --- a/src/mint/taler-mint-httpd_wire.c +++ b/src/mint/taler-mint-httpd_wire.c @@ -106,6 +106,7 @@ TMH_WIRE_handler_wire_test (struct TMH_RequestHandler *rh, GNUNET_break (0); return MHD_NO; } + TMH_RESPONSE_add_global_headers (response); for (i=0;NULL != TMH_expected_wire_formats[i];i++) if (0 == strcasecmp ("test", TMH_expected_wire_formats[i])) @@ -179,6 +180,7 @@ TMH_WIRE_handler_wire_sepa (struct TMH_RequestHandler *rh, GNUNET_break (0); return MHD_NO; } + TMH_RESPONSE_add_global_headers (response); ret = MHD_queue_response (connection, MHD_HTTP_NOT_IMPLEMENTED, response); @@ -225,6 +227,7 @@ TMH_WIRE_handler_wire_sepa (struct TMH_RequestHandler *rh, GNUNET_break (0); return MHD_NO; } + TMH_RESPONSE_add_global_headers (response); if (NULL != rh->mime_type) (void) MHD_add_response_header (response, MHD_HTTP_HEADER_CONTENT_TYPE, |