From e9c8d709923429c8633e36dcf6bbc5676246d10b Mon Sep 17 00:00:00 2001
From: Dmitriy Gerasimov <dmitry.gerasimov@demlabs.net>
Date: Tue, 10 Aug 2021 18:26:45 +0700
Subject: [PATCH] [*] Replaced handler struct with UUID based checks

---
 dap-sdk/net/client/dap_client_http.c | 16 ++++++++--------
 modules/net/dap_chain_node_client.c  |  1 -
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/dap-sdk/net/client/dap_client_http.c b/dap-sdk/net/client/dap_client_http.c
index 1d68668eb5..a8a3e6c471 100644
--- a/dap-sdk/net/client/dap_client_http.c
+++ b/dap-sdk/net/client/dap_client_http.c
@@ -219,13 +219,13 @@ static bool s_timer_timeout_after_connected_check(void * a_arg)
  */
 static bool s_timer_timeout_check(void * a_arg)
 {
-    dap_events_socket_handle_t *l_es_handler = (dap_events_socket_handle_t*) a_arg;
-    assert(l_es_handler);
+    dap_events_socket_uuid_t *l_es_uuid = (dap_events_socket_uuid_t*) a_arg;
+    assert(l_es_uuid);
 
     dap_worker_t * l_worker = dap_events_get_current_worker(dap_events_get_default()); // We're in own esocket context
     assert(l_worker);
     dap_events_socket_t * l_es;
-    if(l_es = dap_worker_esocket_find_uuid(l_worker, l_es_handler->esocket_uuid)){
+    if(l_es = dap_worker_esocket_find_uuid(l_worker, *l_es_uuid)){
         if (l_es->flags & DAP_SOCK_CONNECTING ){
             dap_client_http_pvt_t * l_http_pvt = PVT(l_es);
             log_it(L_WARNING,"Connecting timeout for request http://%s:%u/%s, possible network problems or host is down",
@@ -243,9 +243,9 @@ static bool s_timer_timeout_check(void * a_arg)
                 log_it(L_DEBUG,"Socket %d is connected, close check timer", l_es->socket);
     }else
         if(s_debug_more)
-            log_it(L_DEBUG,"Esocket %llu is finished, close check timer", l_es_handler->esocket_uuid);
+            log_it(L_DEBUG,"Esocket %llu is finished, close check timer", *l_es_uuid);
 
-    DAP_DEL_Z(l_es_handler)
+    DAP_DEL_Z(l_es_uuid);
     return false;
 }
 
@@ -635,9 +635,9 @@ void* dap_client_http_request_custom(dap_worker_t * a_worker, const char *a_upli
         log_it(L_DEBUG, "Connecting to %s:%u", a_uplink_addr, a_uplink_port);
         l_http_pvt->worker = a_worker?a_worker: dap_events_worker_get_auto();
         dap_worker_add_events_socket(l_ev_socket,l_http_pvt->worker);
-        dap_events_socket_handle_t * l_ev_socket_handler = DAP_NEW_Z(dap_events_socket_handle_t);
-        l_ev_socket_handler->esocket_uuid = l_ev_socket->uuid;
-        dap_timerfd_start_on_worker(l_http_pvt->worker,s_client_timeout_ms, s_timer_timeout_check,l_ev_socket_handler);
+        dap_events_socket_uuid_t * l_ev_uuid = DAP_NEW_Z(dap_events_socket_uuid_t);
+        *l_ev_uuid = l_ev_socket->uuid;
+        dap_timerfd_start_on_worker(l_http_pvt->worker,s_client_timeout_ms, s_timer_timeout_check,l_ev_uuid);
         return l_http_pvt;
     }
     else{
diff --git a/modules/net/dap_chain_node_client.c b/modules/net/dap_chain_node_client.c
index 5895f61e3a..a0df55ee08 100644
--- a/modules/net/dap_chain_node_client.c
+++ b/modules/net/dap_chain_node_client.c
@@ -226,7 +226,6 @@ static bool s_timer_update_states_callback(void * a_arg )
                                                                     l_chain_id.uint64, l_net->pub.cell_id.uint64,
                                                           &l_sync_gdb, sizeof(l_sync_gdb));
                 }
-                DAP_DELETE(l_uuid);
                 return true;
             }
         }
-- 
GitLab