From ff69837f19afc047a0c72ae88e41468685640344 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Wed, 10 Jul 2024 18:11:58 +0100 Subject: [PATCH] add LOGIN_TIMEOUT macro --- src/wrapper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wrapper.c b/src/wrapper.c index 002c4b2..bc3e3c4 100644 --- a/src/wrapper.c +++ b/src/wrapper.c @@ -18,6 +18,7 @@ #define KIND_STR_LEN 64 #define VERSION_STR_LEN 32 +#define LOGIN_TIMEOUT 2 /** * @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)); } - int timeout = 2; time_t start = time(NULL); do { @@ -57,7 +57,7 @@ long login(PT_VMR vmr, int kind) break; } Sleep(50); - } while (time(NULL) < start + timeout); + } while (difftime(time(NULL), start) < LOGIN_TIMEOUT); if (rep == 0) {