diff --git a/net/server/cli_server/dap_cli_server.c b/net/server/cli_server/dap_cli_server.c index 7a42efeab3f9aae55a6f8d38540011719cea4e24..7d3d0e68b9d41b2300e7889f9420a72c7488d8bf 100644 --- a/net/server/cli_server/dap_cli_server.c +++ b/net/server/cli_server/dap_cli_server.c @@ -54,6 +54,7 @@ static dap_server_t *s_cli_server = NULL; static bool s_debug_cli = false; +static atomic_int_fast64_t s_cmd_thread_count = 0; static dap_cli_cmd_t *cli_commands = NULL; static dap_cli_cmd_aliases_t *s_command_alias = NULL; @@ -424,6 +425,7 @@ dap_cli_cmd_t *dap_cli_server_cmd_find_by_alias(const char *a_alias, char **a_ap } static void *s_cli_cmd_exec(void *a_arg) { + atomic_fetch_add(&s_cmd_thread_count, 1); cli_cmd_arg_t *l_arg = (cli_cmd_arg_t*)a_arg; char *l_ret = dap_cli_cmd_exec(l_arg->buf), *l_full_ret = dap_strdup_printf("HTTP/1.1 200 OK\r\n" @@ -433,6 +435,7 @@ static void *s_cli_cmd_exec(void *a_arg) { dap_events_socket_write_mt(l_arg->worker, l_arg->es_uid, l_full_ret, dap_strlen(l_full_ret)); // TODO: pagination DAP_DEL_MULTY(l_arg->buf, /* l_full_ret, */ l_arg); + atomic_fetch_sub(&s_cmd_thread_count, 1); return NULL; } @@ -542,3 +545,8 @@ char *dap_cli_cmd_exec(char *a_req_str) { dap_json_rpc_request_free(request); return response_string; } + +DAP_INLINE int64_t dap_cli_get_cmd_thread_count() +{ + return atomic_load(&s_cmd_thread_count); +} \ No newline at end of file diff --git a/net/server/cli_server/include/dap_cli_server.h b/net/server/cli_server/include/dap_cli_server.h index 326471849f4d85ab66786dab776c3ba4962107c5..baa9f82bd4a087028d069a5de760d614c239620a 100644 --- a/net/server/cli_server/include/dap_cli_server.h +++ b/net/server/cli_server/include/dap_cli_server.h @@ -75,6 +75,7 @@ dap_cli_cmd_t* dap_cli_server_cmd_find(const char *a_name); void dap_cli_server_alias_add(const char *a_alias, const char *a_pre_cmd, dap_cli_cmd_t *a_cmd); dap_cli_cmd_t *dap_cli_server_cmd_find_by_alias(const char *a_cli, char **a_append, char **a_ncmd); +int64_t dap_cli_get_cmd_thread_count(); //for json int json_commands(const char * a_name);