Default timeout parameter added

When we're modifying the binary format, we can introduce host-dependent
timeouts as well.
This commit is contained in:
Johannes Bauer 2021-06-27 12:51:51 +02:00
parent 37b239b179
commit 323db6d08d
3 changed files with 14 additions and 3 deletions

View File

@ -231,10 +231,20 @@ static bool abort_searching_for_keyserver(struct keyclient_t *keyclient) {
return true;
}
unsigned int client_timeout_secs = 0;
if (keyclient->opts->timeout_seconds) {
/* Command line always has precedence */
client_timeout_secs = keyclient->opts->timeout_seconds;
} else {
/* Alternatively, take the one in the configuration file */
client_timeout_secs = keyclient->keydb->hosts[0].client_default_timeout_secs;
}
if (client_timeout_secs) {
double time_passed = now() - keyclient->broadcast_start_time;
if (time_passed >= keyclient->opts->timeout_seconds) {
log_msg(LLVL_WARNING, "Could not unlock all volumes after %u seconds, giving up. %d volumes still locked.", keyclient->opts->timeout_seconds, locked_volume_count(keyclient));
if (time_passed >= client_timeout_secs) {
log_msg(LLVL_WARNING, "Could not unlock all volumes after %u seconds, giving up. %d volumes still locked.", client_timeout_secs, locked_volume_count(keyclient));
return true;
}
}

View File

@ -332,7 +332,7 @@ static keydb_t* keydb_migrate(void **keydb_data, unsigned int *keydb_data_size)
header = *((struct keydb_common_header_t**)keydb_data);
if (header->keydb_version == 3) {
if (*keydb_data_size != keydb_getsize_v3(*keydb_data)) {
log_msg(LLVL_ERROR, "keydb version 3 has wrong size (%u bytes, but expected %u bytes).", *keydb_data_size, keydb_getsize_v2(*keydb_data));
log_msg(LLVL_ERROR, "keydb version 3 has wrong size (%u bytes, but expected %u bytes).", *keydb_data_size, keydb_getsize_v3(*keydb_data));
return NULL;
}
}

View File

@ -78,6 +78,7 @@ struct host_entry_v3_t {
char host_name[MAX_HOST_NAME_LENGTH]; /* Descriptive name of host */
uint8_t tls_psk[PSK_SIZE_BYTES]; /* Raw byte data of TLS-PSK that is used */
unsigned int volume_count; /* Number of volumes of this host */
unsigned int client_default_timeout_secs; /* Client gives up by default if not everything unlocked after this time */
unsigned int host_flags; /* Bitset of enum host_flag_t */
struct volume_entry_v3_t volumes[MAX_VOLUMES_PER_HOST]; /* Volumes of this host */
} ALIGNED;