From ca97b45059f7afc809991ea64ec14abc1d4f4485 Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Fri, 30 Aug 2024 00:31:59 +0200 Subject: [PATCH] solved infinite loop in read_socket_raw by the worst possible solution but yeahhh --- src/chat/misc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/chat/misc.c b/src/chat/misc.c index d110239..3715a4f 100644 --- a/src/chat/misc.c +++ b/src/chat/misc.c @@ -154,6 +154,11 @@ char *read_socket_raw(int socket) char *content_buffer = NULL; int content_size; + char *wait_buffer = why2_malloc(2); //TEMP + + //WAIT TILl RECEIVED MSG (ik it sucks but i can't think of better solution; anyways, this is way more convenient than infinite loop that makes my computer go wroom wroom) + recv(socket, wait_buffer, 1, MSG_PEEK); + why2_deallocate(wait_buffer); why2_bool empty_buffer = 0; //WHETHER MSG_PEEK SHOULD BE USER OR NOT @@ -161,7 +166,7 @@ char *read_socket_raw(int socket) { //FIND THE SENT SIZE content_size = 0; - if (ioctl(socket, FIONREAD, &content_size) < 0 || content_size <= 0) continue; //TODO: Infinite loop + if (ioctl(socket, FIONREAD, &content_size) < 0 || content_size <= 0) continue; //ALLOCATE content_buffer = why2_realloc(content_buffer, content_size + 1);