diff --git a/dap-sdk/net/client/dap_client_http.c b/dap-sdk/net/client/dap_client_http.c index 41405e258a1d0b285bbd442e60f150569a9ee6cd..bc66333e38aa96eeb89bd388f95eef9c97155fad 100644 --- a/dap-sdk/net/client/dap_client_http.c +++ b/dap-sdk/net/client/dap_client_http.c @@ -126,8 +126,10 @@ static bool s_timer_timeout_check(void * a_arg) dap_client_http_pvt_t * l_http_pvt = PVT(l_es); log_it(L_WARNING,"Connection timeout for request http://%s:%u/%s, possible network problems or host is down", l_http_pvt->uplink_addr, l_http_pvt->uplink_port, l_http_pvt->path); - if(l_http_pvt->error_callback) + if(l_http_pvt->error_callback) { l_http_pvt->error_callback(ETIMEDOUT, l_http_pvt->obj); + l_http_pvt->were_callbacks_called = true; + } l_http_pvt->is_closed_by_timeout = true; l_es->flags |= DAP_SOCK_SIGNAL_CLOSE; } @@ -300,7 +302,8 @@ static void s_es_delete(dap_events_socket_t * a_es, void * a_arg) l_client_http_internal->were_callbacks_called = true; } } - s_client_http_delete(PVT(a_es)); + s_client_http_delete(l_client_http_internal); + a_es->_inheritor = NULL; } /** @@ -317,22 +320,16 @@ static void s_client_http_delete(dap_client_http_pvt_t * a_http_pvt) return; } - if(a_http_pvt->method) - DAP_DEL_Z(a_http_pvt->method); - if(a_http_pvt->request_content_type) - DAP_DEL_Z(a_http_pvt->request_content_type); - if(a_http_pvt->uplink_addr ) - DAP_DEL_Z(a_http_pvt->uplink_addr); - if (a_http_pvt->cookie) - DAP_DEL_Z(a_http_pvt->cookie); - if(a_http_pvt->response) - DAP_DEL_Z(a_http_pvt->response); - if(a_http_pvt->path) - DAP_DEL_Z(a_http_pvt->path); - if(a_http_pvt->request) - DAP_DEL_Z(a_http_pvt->request); - if(a_http_pvt->request_custom_headers) - DAP_DEL_Z(a_http_pvt->request_custom_headers); + DAP_DEL_Z(a_http_pvt->method) + DAP_DEL_Z(a_http_pvt->request_content_type) + DAP_DEL_Z(a_http_pvt->uplink_addr) + DAP_DEL_Z(a_http_pvt->cookie) + DAP_DEL_Z(a_http_pvt->response) + DAP_DEL_Z(a_http_pvt->path) + DAP_DEL_Z(a_http_pvt->request) + DAP_DEL_Z(a_http_pvt->request_custom_headers) + a_http_pvt->obj = NULL; + DAP_DEL_Z(a_http_pvt) } @@ -467,6 +464,7 @@ void* dap_client_http_request_custom(dap_worker_t * a_worker,const char *a_uplin return NULL; } } + l_ev_socket->remote_addr_str = dap_strdup(a_uplink_addr); // connect l_ev_socket->remote_addr.sin_family = AF_INET; l_ev_socket->remote_addr.sin_port = htons(a_uplink_port); diff --git a/dap-sdk/net/core/dap_events_socket.c b/dap-sdk/net/core/dap_events_socket.c index 3b87cbe912e4d69aa055b541723694fb2f627f33..8e5a2ccb17e4c717696df17e7dd05d8e8cab6c77 100644 --- a/dap-sdk/net/core/dap_events_socket.c +++ b/dap-sdk/net/core/dap_events_socket.c @@ -435,9 +435,9 @@ dap_events_socket_t * dap_events_socket_queue_ptr_create_input(dap_events_socket WCHAR l_direct_name[MQ_MAX_Q_NAME_LEN] = { 0 }; int pos = 0; #ifdef DAP_BRAND - pos = _snwprintf_s(l_direct_name, sizeof(l_direct_name)/sizeof(l_direct_name[0]), _TRUNCATE, L"DIRECT=OS:.\\PRIVATE$\\" DAP_BRAND "__esmq%d", l_es->mq_num); + pos = _snwprintf_s(l_direct_name, sizeof(l_direct_name)/sizeof(l_direct_name[0]), _TRUNCATE, L"DIRECT=OS:.\\PRIVATE$\\" DAP_BRAND "_esmq%d", l_es->mq_num); #else - pos = _snwprintf_s(l_direct_name, sizeof(l_direct_name)/sizeof(l_direct_name[0]), _TRUNCATE, L"DIRECT=OS:.\\PRIVATE$\\%hs__esmq%d", dap_get_appname(), l_es->mq_num); + pos = _snwprintf_s(l_direct_name, sizeof(l_direct_name)/sizeof(l_direct_name[0]), _TRUNCATE, L"DIRECT=OS:.\\PRIVATE$\\%hs_esmq%d", dap_get_appname(), l_es->mq_num); #endif if (pos < 0) { log_it(L_ERROR, "Message queue path error"); @@ -608,9 +608,9 @@ dap_events_socket_t * s_create_type_queue_ptr(dap_worker_t * a_w, dap_events_soc static atomic_uint s_queue_num = 0; int pos = 0; #ifdef DAP_BRAND - pos = _snwprintf_s(l_pathname, sizeof(l_pathname)/sizeof(l_pathname[0]), _TRUNCATE, L".\\PRIVATE$\\" DAP_BRAND "__esmq%d", l_es->mq_num = s_queue_num++); + pos = _snwprintf_s(l_pathname, sizeof(l_pathname)/sizeof(l_pathname[0]), _TRUNCATE, L".\\PRIVATE$\\" DAP_BRAND "_esmq%d", l_es->mq_num = s_queue_num++); #else - pos = _snwprintf_s(l_pathname, sizeof(l_pathname)/sizeof(l_pathname[0]), _TRUNCATE, L".\\PRIVATE$\\%hs__esmq%d", dap_get_appname(), l_es->mq_num = s_queue_num++); + pos = _snwprintf_s(l_pathname, sizeof(l_pathname)/sizeof(l_pathname[0]), _TRUNCATE, L".\\PRIVATE$\\%hs_esmq%d", dap_get_appname(), l_es->mq_num = s_queue_num++); #endif if (pos < 0) { log_it(L_ERROR, "Message queue path error"); @@ -1404,6 +1404,7 @@ void dap_events_socket_delete_unsafe( dap_events_socket_t * a_esocket , bool a_p DAP_DEL_Z(a_esocket->_pvt) DAP_DEL_Z(a_esocket->buf_in) DAP_DEL_Z(a_esocket->buf_out) + DAP_DEL_Z(a_esocket->remote_addr_str) #ifdef DAP_OS_WINDOWS if ( a_esocket->socket && a_esocket->socket != INVALID_SOCKET) { closesocket( a_esocket->socket ); diff --git a/dap-sdk/net/core/dap_worker.c b/dap-sdk/net/core/dap_worker.c index bd1fed58958775c5eb5efaf4b5aba39a188f9bb0..a716e96214d1f39dc057abda93b204dedad79604 100644 --- a/dap-sdk/net/core/dap_worker.c +++ b/dap-sdk/net/core/dap_worker.c @@ -632,10 +632,10 @@ void *dap_worker_thread(void *arg) if ((l_cur->flags & DAP_SOCK_SIGNAL_CLOSE) && !l_cur->no_close) { if (l_cur->buf_out_size == 0) { - log_it(L_INFO, "Process signal to close %s, sock %u [thread %u]", l_cur->hostaddr, l_cur->socket, l_tn); + log_it(L_INFO, "Process signal to close %s, sock %u [thread %u]", l_cur->remote_addr_str, l_cur->socket, l_tn); dap_events_socket_remove_and_delete_unsafe( l_cur, false); } else if (l_cur->buf_out_size ) { - log_it(L_INFO, "Got signal to close %s, sock %u [thread %u] but buffer is not empty(%zd)", l_cur->hostaddr, l_cur->socket, l_tn, + log_it(L_INFO, "Got signal to close %s, sock %u [thread %u] but buffer is not empty(%zd)", l_cur->remote_addr_str, l_cur->socket, l_tn, l_cur->buf_out_size); } } diff --git a/dap-sdk/net/server/http_server/http_client/dap_http_client.c b/dap-sdk/net/server/http_server/http_client/dap_http_client.c index f1b05054d579bdcc9be655d2eefa9464e315ed20..64f1b00468ccae7238074e2f708a624b0159eb6b 100644 --- a/dap-sdk/net/server/http_server/http_client/dap_http_client.c +++ b/dap-sdk/net/server/http_server/http_client/dap_http_client.c @@ -107,10 +107,7 @@ void dap_http_client_delete( dap_events_socket_t * cl, void *arg ) cl_ht->proc->delete_callback( cl_ht, NULL ); } } - - if( cl_ht->_inheritor ) { - free( cl_ht->_inheritor ); - } + DAP_DEL_Z(cl_ht->_inheritor) (void) arg; }