removed the stupid goto another way
All checks were successful
Codacy Scan / Codacy Security Scan (push) Successful in 11s
Build WHY2-chat / test-why2 (./out/why2-chat-client, ./configure.sh, ubuntu-latest, ./out/why2-chat-server) (push) Successful in 1m48s
Test Project / test-project (./configure.sh, gdb -ex "run" -ex "quit" --batch, ubuntu-latest, ./test) (push) Successful in 1m50s
Test WHY2-core / test-why2 (why2, ./configure.sh, gdb -ex "run" -ex "quit" --batch, ubuntu-latest, ./out/why2-core-test, valgrind --leak-check=full --show-leak-kinds=reachable --track-origins=yes -s) (push) Successful in 2m33s
Test WHY2-logger / test-why2 (why2-logger, ./configure.sh, gdb -ex "run" -ex "quit" --batch, ubuntu-latest, ./out/why2-logger-test, valgrind --leak-check=full --show-leak-kinds=reachable --track-origins=yes -s) (push) Successful in 2m43s
All checks were successful
Codacy Scan / Codacy Security Scan (push) Successful in 11s
Build WHY2-chat / test-why2 (./out/why2-chat-client, ./configure.sh, ubuntu-latest, ./out/why2-chat-server) (push) Successful in 1m48s
Test Project / test-project (./configure.sh, gdb -ex "run" -ex "quit" --batch, ubuntu-latest, ./test) (push) Successful in 1m50s
Test WHY2-core / test-why2 (why2, ./configure.sh, gdb -ex "run" -ex "quit" --batch, ubuntu-latest, ./out/why2-core-test, valgrind --leak-check=full --show-leak-kinds=reachable --track-origins=yes -s) (push) Successful in 2m33s
Test WHY2-logger / test-why2 (why2-logger, ./configure.sh, gdb -ex "run" -ex "quit" --batch, ubuntu-latest, ./out/why2-logger-test, valgrind --leak-check=full --show-leak-kinds=reachable --track-origins=yes -s) (push) Successful in 2m43s
simply deleted it lol - i have no clue why i used the MSG_PEEK in the first place tho
This commit is contained in:
parent
99695875b1
commit
94969b5588
@ -173,8 +173,6 @@ char *read_socket_raw(int socket)
|
|||||||
recv(socket, wait_buffer, 1, MSG_PEEK);
|
recv(socket, wait_buffer, 1, MSG_PEEK);
|
||||||
why2_deallocate(wait_buffer);
|
why2_deallocate(wait_buffer);
|
||||||
|
|
||||||
why2_bool empty_buffer = 0; //WHETHER MSG_PEEK SHOULD BE USER OR NOT
|
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
//FIND THE SENT SIZE
|
//FIND THE SENT SIZE
|
||||||
@ -184,23 +182,13 @@ char *read_socket_raw(int socket)
|
|||||||
//ALLOCATE
|
//ALLOCATE
|
||||||
content_buffer = why2_realloc(content_buffer, content_size + 1);
|
content_buffer = why2_realloc(content_buffer, content_size + 1);
|
||||||
|
|
||||||
read_section:
|
|
||||||
|
|
||||||
//READ JSON MESSAGE
|
//READ JSON MESSAGE
|
||||||
if (recv(socket, content_buffer, content_size, !empty_buffer ? MSG_PEEK : 0) != content_size) //READ THE MESSAGE BY CHARACTERS
|
if (recv(socket, content_buffer, content_size, 0) != content_size) //READ THE MESSAGE BY CHARACTERS
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Socket probably read wrongly!\n");
|
fprintf(stderr, "Socket probably read wrongly!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty_buffer) goto return_section; //STOP LOOPING
|
|
||||||
} while (content_buffer == NULL || strncmp(content_buffer + (content_size - 2), "\"}", 2) != 0);
|
} while (content_buffer == NULL || strncmp(content_buffer + (content_size - 2), "\"}", 2) != 0);
|
||||||
|
|
||||||
//REMOVE JUNK FROM BUFFER (CUZ THE MSG_PEEK FLAG)
|
|
||||||
empty_buffer = 1;
|
|
||||||
goto read_section; //TODO: remove the stupid goto
|
|
||||||
|
|
||||||
return_section:
|
|
||||||
|
|
||||||
content_buffer[content_size] = '\0'; //NULL TERM
|
content_buffer[content_size] = '\0'; //NULL TERM
|
||||||
|
|
||||||
//VALIDATE JSON FORMAT
|
//VALIDATE JSON FORMAT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user