From: Holger Schemel Date: Sat, 30 Oct 2021 18:16:15 +0000 (+0200) Subject: added counting active API threads X-Git-Tag: 4.3.0.0~6 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=746d91a67b5059c607e8e6bd0453e6e0738ffe45;p=rocksndiamonds.git added counting active API threads --- diff --git a/src/files.c b/src/files.c index 535b1d52..4c5a3661 100644 --- a/src/files.c +++ b/src/files.c @@ -9280,12 +9280,16 @@ static int ApiGetScoreThread(void *data_raw) struct HttpRequest *request = checked_calloc(sizeof(struct HttpRequest)); struct HttpResponse *response = checked_calloc(sizeof(struct HttpResponse)); + program.api_thread_count++; + #if defined(PLATFORM_EMSCRIPTEN) Emscripten_ApiGetScore_HttpRequest(request, data_raw); #else ApiGetScore_HttpRequest(request, response, data_raw); #endif + program.api_thread_count--; + checked_free(request); checked_free(response); @@ -9679,12 +9683,16 @@ static int ApiAddScoreThread(void *data_raw) struct HttpRequest *request = checked_calloc(sizeof(struct HttpRequest)); struct HttpResponse *response = checked_calloc(sizeof(struct HttpResponse)); + program.api_thread_count++; + #if defined(PLATFORM_EMSCRIPTEN) Emscripten_ApiAddScore_HttpRequest(request, data_raw); #else ApiAddScore_HttpRequest(request, response, data_raw); #endif + program.api_thread_count--; + checked_free(request); checked_free(response); diff --git a/src/libgame/system.c b/src/libgame/system.c index 64aaf0f8..3eb9c62d 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -103,6 +103,8 @@ void InitProgramInfo(char *argv0, char *config_filename, char *userdata_subdir, program.log_file[LOG_OUT_ID] = program.log_file_default[LOG_OUT_ID] = stdout; program.log_file[LOG_ERR_ID] = program.log_file_default[LOG_ERR_ID] = stderr; + program.api_thread_count = 0; + program.headless = FALSE; } diff --git a/src/libgame/system.h b/src/libgame/system.h index c07ab822..11c88762 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -1023,6 +1023,8 @@ struct ProgramInfo void (*exit_message_function)(char *, va_list); void (*exit_function)(int); + int api_thread_count; + boolean headless; }; diff --git a/src/screens.c b/src/screens.c index e72e5786..79d889de 100644 --- a/src/screens.c +++ b/src/screens.c @@ -4229,12 +4229,16 @@ static int ApiRenamePlayerThread(void *data_raw) struct HttpRequest *request = checked_calloc(sizeof(struct HttpRequest)); struct HttpResponse *response = checked_calloc(sizeof(struct HttpResponse)); + program.api_thread_count++; + #if defined(PLATFORM_EMSCRIPTEN) Emscripten_ApiRenamePlayer_HttpRequest(request, data_raw); #else ApiRenamePlayer_HttpRequest(request, response, data_raw); #endif + program.api_thread_count--; + checked_free(request); checked_free(response);