From b9c74af8f002e9b1ff83a5715e289dbdd23e686f Mon Sep 17 00:00:00 2001 From: Namonay Date: Mon, 22 Jan 2024 17:23:34 +0100 Subject: [PATCH] malaise --- includes/server.hpp | 4 ++-- srcs/main.cpp | 4 ++-- srcs/server.cpp | 5 ++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/includes/server.hpp b/includes/server.hpp index 8ed5866..4c5225e 100644 --- a/includes/server.hpp +++ b/includes/server.hpp @@ -6,7 +6,7 @@ /* By: vvaas +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/21 09:12:28 by maldavid #+# #+# */ -/* Updated: 2024/01/22 17:00:02 by maldavid ### ########.fr */ +/* Updated: 2024/01/22 17:21:23 by vvaas ### ########.fr */ /* */ /******************************************************************************/ @@ -28,7 +28,7 @@ namespace irc public: Server(int port, const std::string& password); - inline void closeMainSocket() { close(_main_socket); } + inline void closeMainSocket() { if (_main_socket > 0) close(_main_socket); _main_socket = 0; _active = false; } void wait(); ~Server(); diff --git a/srcs/main.cpp b/srcs/main.cpp index e0bc160..202a7c0 100644 --- a/srcs/main.cpp +++ b/srcs/main.cpp @@ -6,7 +6,7 @@ /* By: vvaas +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/20 09:27:04 by maldavid #+# #+# */ -/* Updated: 2024/01/22 17:04:37 by maldavid ### ########.fr */ +/* Updated: 2024/01/22 17:23:14 by vvaas ### ########.fr */ /* */ /******************************************************************************/ @@ -23,7 +23,7 @@ static unstd::SharedPtr server_ref; void signalsHandler(int foo) { (void)foo; - if(server_ref) + if (!server_ref) return; server_ref->closeMainSocket(); } diff --git a/srcs/server.cpp b/srcs/server.cpp index f87a602..d56c73b 100644 --- a/srcs/server.cpp +++ b/srcs/server.cpp @@ -6,7 +6,7 @@ /* By: vvaas +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/21 09:31:17 by maldavid #+# #+# */ -/* Updated: 2024/01/22 17:00:42 by maldavid ### ########.fr */ +/* Updated: 2024/01/22 17:23:23 by vvaas ### ########.fr */ /* */ /******************************************************************************/ @@ -101,7 +101,7 @@ namespace irc FD_SET((*it)->getFD(), &_fd_set); tmp = select(MAX_USERS, &_fd_set, NULL, NULL, NULL); // SELECT blocks till a connection or message is received, and let only those in _fd_set - if(tmp < 0) + if(tmp < 0 && _main_socket != 0) logs::report(log_fatal_error, "select fd error"); if(FD_ISSET(_main_socket, &_fd_set)) // if it's a new connection @@ -118,7 +118,6 @@ namespace irc logs::report(log_message, "User %d connected", _client.back()->getID()); } - handleInput(); } }