This commit is contained in:
jeka committed 2026-03-06 01:36:57 +03:00
1 parent b2640e7201
commit 15c7968c8c
34 files changed
+332 -284

No files matched your search

+10 -9
View File
@@ -11,6 +11,7 @@
#include "tun_if.h"
#include "../lib/u_async.h"
#include "../lib/debug_config.h"
#include "../lib/mem.h"
#include <stdlib.h>
#include <string.h>
@@ -332,7 +333,7 @@ static void accept_callback(socket_t fd, void* arg) {
}
/* Allocate client structure */
struct control_client* client = (struct control_client*)calloc(1, sizeof(*client));
struct control_client* client = (struct control_client*)u_calloc(1, sizeof(*client));
if (!client) {
if (server->log_file) {
fprintf(server->log_file, "%llu: [ERROR] Failed to allocate client structure\n",
@@ -367,7 +368,7 @@ static void accept_callback(socket_t fd, void* arg) {
fflush(server->log_file);
}
DEBUG_ERROR(DEBUG_CATEGORY_CONTROL, "Failed to register client socket with uasync");
free(client);
u_free(client);
#ifdef _WIN32
closesocket(client_fd);
#else
@@ -526,7 +527,7 @@ static void close_client(struct control_server* server, struct control_client* c
}
server->client_count--;
free(client);
u_free(client);
DEBUG_INFO(DEBUG_CATEGORY_CONTROL, "Control client disconnected (total: %u)",
server->client_count);
@@ -642,7 +643,7 @@ static void send_conn_list(struct control_server* server, struct control_client*
/* Build response */
uint16_t rsp_size = ETCPMON_CONN_LIST_SIZE(count);
uint8_t* buffer = (uint8_t*)malloc(rsp_size);
uint8_t* buffer = (uint8_t*)u_malloc(rsp_size);
if (!buffer) {
DEBUG_ERROR(DEBUG_CATEGORY_CONTROL, "Failed to allocate connection list buffer");
return;
@@ -679,7 +680,7 @@ static void send_conn_list(struct control_server* server, struct control_client*
send(client->fd, buffer, rsp_size, 0);
#endif
free(buffer);
u_free(buffer);
}
static void send_metrics(struct control_server* server, struct control_client* client) {
@@ -702,7 +703,7 @@ static void send_metrics(struct control_server* server, struct control_client* c
/* Build response */
uint16_t rsp_size = ETCPMON_METRICS_SIZE(links_count);
uint8_t* buffer = (uint8_t*)malloc(rsp_size);
uint8_t* buffer = (uint8_t*)u_malloc(rsp_size);
if (!buffer) {
DEBUG_ERROR(DEBUG_CATEGORY_CONTROL, "Failed to allocate metrics buffer");
return;
@@ -775,7 +776,7 @@ static void send_metrics(struct control_server* server, struct control_client* c
send(client->fd, buffer, rsp_size, 0);
#endif
free(buffer);
u_free(buffer);
}
static void send_error(struct control_client* client, uint8_t error_code, const char* msg) {
@@ -783,7 +784,7 @@ static void send_error(struct control_client* client, uint8_t error_code, const
uint16_t msg_len = (uint16_t)strlen(msg);
uint16_t rsp_size = ETCPMON_ERROR_SIZE(msg_len);
uint8_t* buffer = (uint8_t*)malloc(rsp_size);
uint8_t* buffer = (uint8_t*)u_malloc(rsp_size);
if (!buffer) return;
struct etcpmon_msg_header* hdr = (struct etcpmon_msg_header*)buffer;
@@ -808,7 +809,7 @@ static void send_error(struct control_client* client, uint8_t error_code, const
send(client->fd, buffer, rsp_size, 0);
#endif
free(buffer);
u_free(buffer);
}
/* ============================================================================