From 14bdbdaa22b062a8a7301f78e36fc4940eef978a Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Wed, 13 Dec 2023 00:04:18 +0100 Subject: main_event_loop: set and check 'sockfd' --- FICS/ficsmain.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'FICS') diff --git a/FICS/ficsmain.c b/FICS/ficsmain.c index ddc8b70..1317955 100644 --- a/FICS/ficsmain.c +++ b/FICS/ficsmain.c @@ -101,14 +101,17 @@ PRIVATE void main_event_loop(void) { char command_string[MAX_STRING_LENGTH]; - int sockfd; + int sockfd = -1; while (1) { ngc2(command_string, HEARTBEATTIME); - if (process_heartbeat(&sockfd) == COM_LOGOUT) { + + if (process_heartbeat(&sockfd) == COM_LOGOUT && sockfd != -1) { process_disconnection(sockfd); net_close_connection(sockfd); } + + sockfd = -1; } } -- cgit v1.2.3