From eb76a010d91d5362351a9e67bf7a04ac65786065 Mon Sep 17 00:00:00 2001 From: "Constantin P." <papizh.konstantin@demlabs.net> Date: Mon, 3 Jun 2024 15:42:42 +0000 Subject: [PATCH] Hotfix 11832 --- io/dap_server.c | 6 +++--- net/server/notify_server/include/dap_notify_srv.h | 2 ++ net/server/notify_server/src/dap_notify_srv.c | 7 +++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/io/dap_server.c b/io/dap_server.c index 5b3e09de7..70f77727d 100644 --- a/io/dap_server.c +++ b/io/dap_server.c @@ -495,13 +495,13 @@ static void s_es_server_accept(dap_events_socket_t *a_es_listener, SOCKET a_remo #endif l_es_new->worker = l_worker; l_es_new->last_time_active = time(NULL); - if (l_es_new->callbacks.new_callback) - l_es_new->callbacks.new_callback(l_es_new, NULL); - l_es_new->is_initalized = true; if (dap_worker_add_events_socket_unsafe(l_worker, l_es_new)) { log_it(L_CRITICAL, "Can't add event socket's handler to worker i/o poll mechanism with error %d", errno); return; } + if (l_es_new->callbacks.new_callback) + l_es_new->callbacks.new_callback(l_es_new, NULL); + l_es_new->is_initalized = true; debug_if(g_debug_reactor, L_INFO, "Direct addition of esocket %p uuid 0x%"DAP_UINT64_FORMAT_x" to worker %d", l_es_new, l_es_new->uuid, l_worker->id); } else diff --git a/net/server/notify_server/include/dap_notify_srv.h b/net/server/notify_server/include/dap_notify_srv.h index f93bfa10b..43904e188 100644 --- a/net/server/notify_server/include/dap_notify_srv.h +++ b/net/server/notify_server/include/dap_notify_srv.h @@ -30,3 +30,5 @@ void dap_notify_server_deinit(); DAP_PRINTF_ATTR(2, 3) int dap_notify_server_send_f_inter(uint32_t a_worker_id, const char *a_format, ...); int dap_notify_server_send_mt(const char * a_data); DAP_PRINTF_ATTR(1, 2) int dap_notify_server_send_f_mt(const char *a_format, ...); + +void dap_notify_srv_set_callback_new(dap_events_socket_callback_t); \ No newline at end of file diff --git a/net/server/notify_server/src/dap_notify_srv.c b/net/server/notify_server/src/dap_notify_srv.c index 18217b835..f0caf1fad 100644 --- a/net/server/notify_server/src/dap_notify_srv.c +++ b/net/server/notify_server/src/dap_notify_srv.c @@ -49,6 +49,11 @@ static void s_notify_server_callback_queue(dap_events_socket_t * a_es, void * a_ static void s_notify_server_callback_new(dap_events_socket_t * a_es, void * a_arg); static void s_notify_server_callback_delete(dap_events_socket_t * a_es, void * a_arg); +dap_events_socket_callback_t s_notify_server_callback_new_ex = NULL; + +void dap_notify_srv_set_callback_new(dap_events_socket_callback_t a_cb) { + s_notify_server_callback_new_ex = a_cb; +} /** * @brief dap_notify_server_init @@ -253,6 +258,8 @@ static void s_notify_server_callback_new(dap_events_socket_t * a_es, UNUSED_ARG HASH_ADD(hh, s_notify_server_clients, uuid, sizeof (l_hh_new->uuid), l_hh_new); } pthread_rwlock_unlock(&s_notify_server_clients_mutex); + if (s_notify_server_callback_new_ex) + s_notify_server_callback_new_ex(a_es, NULL); } /** -- GitLab