From 83c173e22a3ee48e858f057a186e181d61234b69 Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Wed, 19 Apr 2023 12:15:10 +0200 Subject: [PATCH] fixed stop_oldest_thread always working issue no fucking way --- src/chat/misc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/chat/misc.c b/src/chat/misc.c index d2cec01..37e2b2a 100644 --- a/src/chat/misc.c +++ b/src/chat/misc.c @@ -365,13 +365,15 @@ void *why2_communicate_thread(void *arg) //READ pthread_create(&thread_buffer, NULL, read_socket_raw_thread, &connection); - why2_list_push(&waiting_list, &buffer, sizeof(thread_buffer)); //TODO: same address is always passed => stop_oldest_thread works every time; fix your shit + why2_list_push(&waiting_list, &buffer, sizeof(thread_buffer)); //RUN DELETION THREAD pthread_create(&thread_deletion_buffer, NULL, stop_oldest_thread, &thread_buffer); + //WAIT FOR MESSAGE pthread_join(thread_buffer, &raw_ptr); why2_list_remove(&waiting_list, find_request(&thread_buffer)); + pthread_cancel(thread_deletion_buffer); if (raw_ptr == WHY2_INVALID_POINTER || raw_ptr == NULL) break; //QUIT COMMUNICATION IF INVALID PACKET WAS RECEIVED