added counting active API threads
authorHolger Schemel <info@artsoft.org>
Sat, 30 Oct 2021 18:16:15 +0000 (20:16 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Oct 2021 18:16:15 +0000 (20:16 +0200)
src/files.c
src/libgame/system.c
src/libgame/system.h
src/screens.c

index 535b1d520ff0ae0f49e6bbaec4fc66f9fe0b5b90..4c5a366138a27fb6df88a3ce6a2688ce4e82c93b 100644 (file)
@@ -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);
 
index 64aaf0f822210821d3ba5925808d310db6d027e0..3eb9c62d55dc4e42d32de21e5459c876d7542f3d 100644 (file)
@@ -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;
 }
 
index c07ab82298cb38cfe8da9947a6af06041c748da8..11c88762ff96f9fbd2dd275050b57fd1bbe25d9d 100644 (file)
@@ -1023,6 +1023,8 @@ struct ProgramInfo
   void (*exit_message_function)(char *, va_list);
   void (*exit_function)(int);
 
+  int api_thread_count;
+
   boolean headless;
 };
 
index e72e578601bc889dbc2c1e538feb11f1d6b60ee8..79d889de88c886c374e67a041554405b8b0018f9 100644 (file)
@@ -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);