diff options
author | Christian Grothoff <christian@grothoff.org> | 2023-07-05 13:13:16 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2023-07-05 13:13:16 +0200 |
commit | 1db17d43bd9256ec86508bf9e282263e35fd9e01 (patch) | |
tree | a4890ad7cfd49ed5653c0a5ad39bb318b275f6f8 /src/lib/exchange_api_handle.c | |
parent | 999db0fb80c35900b3431b3f90bbd87fca02d983 (diff) |
-misc minor fixesv0.9.3-dev.3
Diffstat (limited to 'src/lib/exchange_api_handle.c')
-rw-r--r-- | src/lib/exchange_api_handle.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/lib/exchange_api_handle.c b/src/lib/exchange_api_handle.c index 0ea7e642b..40ae390fb 100644 --- a/src/lib/exchange_api_handle.c +++ b/src/lib/exchange_api_handle.c @@ -69,6 +69,13 @@ */ #define DEFAULT_EXPIRATION GNUNET_TIME_UNIT_HOURS +/** + * If the "Expire" cache control header is missing, for + * how long do we assume the reply to be valid at least? + */ +#define MINIMUM_EXPIRATION GNUNET_TIME_relative_multiply ( \ + GNUNET_TIME_UNIT_MINUTES, 2) + /** * Handle for a GET /keys request. @@ -1109,6 +1116,20 @@ keys_completed_cb (void *cls, break; } kd->rc = 1; + kd->key_data_expiration = gkh->expire; + if (GNUNET_TIME_relative_cmp ( + GNUNET_TIME_absolute_get_remaining (gkh->expire.abs_time), + <, + MINIMUM_EXPIRATION)) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Exchange returned keys with expiration time below %s. Compensating.\n", + GNUNET_TIME_relative2s (MINIMUM_EXPIRATION, + true)); + kd->key_data_expiration + = GNUNET_TIME_relative_to_timestamp (MINIMUM_EXPIRATION); + } + kresp.details.ok.keys = kd; break; case MHD_HTTP_BAD_REQUEST: |