From e761e0f47250bb4a752d44848febc0f3c7745a4b Mon Sep 17 00:00:00 2001 From: fadhil riyanto Date: Sun, 6 Oct 2024 12:24:18 +0700 Subject: fix fdleak Signed-off-by: fadhil riyanto --- main2.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/main2.c b/main2.c index c0fd3f7..5962a70 100644 --- a/main2.c +++ b/main2.c @@ -658,6 +658,7 @@ static int start_exchange_data(int client_fd, int target_fd) const u_int8_t *bufptr; do { + printf("start sending\n"); memset(buf, 0, 4096); fcntl(client_fd, F_SETFL, O_NONBLOCK); @@ -677,7 +678,7 @@ readbuf: close(client_fd); return 0; } - perror("recv client"); + perror("recv x`client"); printf("clientfd errno %d\n", errno); return 2; } @@ -726,17 +727,20 @@ readbuf_server: } else { // *srvbuf = *srvbuf + ret; // total_srv_read += ret; - send(client_fd, srvbuf, ret, 0); + ret = send(client_fd, srvbuf, ret, 0); + + if (ret == -1) { + perror("send() to client from srv"); + } goto readbuf_server; } - printf("recv from server: %d bytes\n", total_srv_read); // ret = recv(target_fd, buf, 4096, 0); // printf("recv from server: %d bytes\n", ret); // // printf("data: %s\n", buf); // send(client_fd, buf, ret, MSG_DONTWAIT); - // close(client_fd); + close(client_fd); } while (ret != 0); return 0; @@ -804,6 +808,7 @@ static void* start_private_conn_no_epl(void *priv_conn_detailsptr) int ret = start_unpack_packet_no_epl(current_fd, NULL, &socks5_session); if (ret == 0) { printf("connection closed\n"); + } } -- cgit v1.2.3