From 17687e3d13a180000ca2048544f5992f62a24690 Mon Sep 17 00:00:00 2001 From: Dane MacFadden Date: Sun, 10 Aug 2025 00:03:01 -0600 Subject: [PATCH] fixed bug with /c command --- main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 26d3e83..fcb8b57 100644 --- a/main.c +++ b/main.c @@ -86,8 +86,15 @@ void *sender(void *arg) { ListFirst(sendlist); strcpy(msg, (char*)ListCurr(sendlist)); ListRemove(sendlist); - bytes = send(confd, msg, 128, 0); + bytes = send(confd, msg, 128, 0); + /* Stop execution if the user closes the connection */ + if ((strncmp(msg, "/c", 2)) == 0) { + pthread_cancel(receive_thread); + pthread_cancel(input_thread); + pthread_cancel(output_thread); + pthread_exit(&closed); + } /* Check if the message was the command to close the connection */ if ((strncmp(msg, "/c", 2)) == 0) { pthread_cancel(receive_thread);