working on fix for #5747

This commit is contained in:
Christian Grothoff 2019-06-05 23:38:28 +02:00
parent 2f0015b803
commit 69a07468de
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
5 changed files with 52 additions and 17 deletions

View File

@ -15,6 +15,12 @@ REVOCATION_DIR = ${TALER_DATA_HOME}/exchange/revocations/
# This must be adjusted to your actually installation. # This must be adjusted to your actually installation.
# MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG # MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
# How long do we allow /keys to be cached at most? The actual
# limit is the minimum of this value and the first expected
# significant change in /keys based on the expiration times.
# Used to artifically reduce caching (addresses #5747).
MAX_KEYS_CACHING = forever
# How to access our database # How to access our database
DB = postgres DB = postgres

View File

@ -97,6 +97,11 @@ char *TEH_revocation_directory;
*/ */
struct GNUNET_CONFIGURATION_Handle *cfg; struct GNUNET_CONFIGURATION_Handle *cfg;
/**
* How long is caching /keys allowed at most?
*/
struct GNUNET_TIME_Relative max_keys_caching;
/** /**
* Master public key (according to the * Master public key (according to the
* configuration in the exchange directory). * configuration in the exchange directory).
@ -397,7 +402,6 @@ handle_mhd_request (void *cls,
"Only POST is allowed", 0, "Only POST is allowed", 0,
&TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED },
#endif #endif
{ NULL, NULL, NULL, NULL, 0, 0 } { NULL, NULL, NULL, NULL, 0, 0 }
}; };
static struct TEH_RequestHandler h404 = static struct TEH_RequestHandler h404 =
@ -605,6 +609,18 @@ exchange_serve_process_config ()
{ {
char *TEH_master_public_key_str; char *TEH_master_public_key_str;
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_time (cfg,
"exchange",
"MAX_KEYS_CACHING",
&max_keys_caching))
{
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
"exchange",
"MAX_KEYS_CACHING",
"valid relative time expected");
return GNUNET_SYSERR;
}
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (cfg, GNUNET_CONFIGURATION_get_value_filename (cfg,
"exchange", "exchange",

View File

@ -38,6 +38,11 @@ extern char *TEH_exchange_currency_string;
*/ */
extern int TEH_exchange_connection_close; extern int TEH_exchange_connection_close;
/**
* How long is caching /keys allowed at most?
*/
extern struct GNUNET_TIME_Relative max_keys_caching;
/** /**
* The exchange's configuration. * The exchange's configuration.
*/ */

View File

@ -1166,8 +1166,16 @@ setup_general_response_headers (const struct TEH_KS_StateHandle *key_state,
dat)); dat));
if (0 != key_state->next_reload.abs_value_us) if (0 != key_state->next_reload.abs_value_us)
{ {
get_date_string (key_state->next_reload, struct GNUNET_TIME_Absolute m;
m = GNUNET_TIME_relative_to_absolute (max_keys_caching);
m = GNUNET_TIME_absolute_min (m,
key_state->next_reload);
get_date_string (m,
dat); dat);
// FIXME: setting 'm' to FOREVER here exposes
// a crash-bug in lib/ where we access /keys
// data after it was already free'd!
GNUNET_break (MHD_YES == GNUNET_break (MHD_YES ==
MHD_add_response_header (response, MHD_add_response_header (response,
MHD_HTTP_HEADER_EXPIRES, MHD_HTTP_HEADER_EXPIRES,