Restrict number of startup sttempts

This commit is contained in:
Andrey Borodin 2019-12-27 17:00:43 +05:00
parent 887e4aa2d8
commit 465577dca0
1 changed files with 3 additions and 1 deletions

View File

@ -101,13 +101,15 @@ od_frontend_error_is_too_many_connections(od_client_t *client)
return strcmp(error.code, KIWI_TOO_MANY_CONNECTIONS) == 0; return strcmp(error.code, KIWI_TOO_MANY_CONNECTIONS) == 0;
} }
#define MAX_STARTUP_ATTEMPTS 7
static int static int
od_frontend_startup(od_client_t *client) od_frontend_startup(od_client_t *client)
{ {
od_instance_t *instance = client->global->instance; od_instance_t *instance = client->global->instance;
machine_msg_t *msg; machine_msg_t *msg;
while (true) { for (int startup_attempt = 0; startup_attempt < MAX_STARTUP_ATTEMPTS; startup_attempt++) {
msg = od_read_startup(&client->io, client->config_listen->client_login_timeout); msg = od_read_startup(&client->io, client->config_listen->client_login_timeout);
if (msg == NULL) if (msg == NULL)
goto error; goto error;