add LOGIN_TIMEOUT macro

This commit is contained in:
onyx-and-iris 2024-07-10 18:11:58 +01:00
parent b35a29396b
commit ff69837f19

View File

@ -18,6 +18,7 @@
#define KIND_STR_LEN 64 #define KIND_STR_LEN 64
#define VERSION_STR_LEN 32 #define VERSION_STR_LEN 32
#define LOGIN_TIMEOUT 2
/** /**
* @brief Logs into the API. * @brief Logs into the API.
@ -44,7 +45,6 @@ long login(PT_VMR vmr, int kind)
kind_as_string(kind_s, kind, KIND_STR_LEN)); kind_as_string(kind_s, kind, KIND_STR_LEN));
} }
int timeout = 2;
time_t start = time(NULL); time_t start = time(NULL);
do do
{ {
@ -57,7 +57,7 @@ long login(PT_VMR vmr, int kind)
break; break;
} }
Sleep(50); Sleep(50);
} while (time(NULL) < start + timeout); } while (difftime(time(NULL), start) < LOGIN_TIMEOUT);
if (rep == 0) if (rep == 0)
{ {