This commit is contained in:
2024-01-22 17:23:34 +01:00
parent 8ec29c4008
commit b9c74af8f0
3 changed files with 6 additions and 7 deletions

View File

@@ -6,7 +6,7 @@
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */ /* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/21 09:12:28 by maldavid #+# #+# */ /* 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: public:
Server(int port, const std::string& password); 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(); void wait();
~Server(); ~Server();

View File

@@ -6,7 +6,7 @@
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */ /* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/20 09:27:04 by maldavid #+# #+# */ /* 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<irc::Server> server_ref;
void signalsHandler(int foo) void signalsHandler(int foo)
{ {
(void)foo; (void)foo;
if(server_ref) if (!server_ref)
return; return;
server_ref->closeMainSocket(); server_ref->closeMainSocket();
} }

View File

@@ -6,7 +6,7 @@
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */ /* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/21 09:31:17 by maldavid #+# #+# */ /* 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); 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 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"); logs::report(log_fatal_error, "select fd error");
if(FD_ISSET(_main_socket, &_fd_set)) // if it's a new connection 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()); logs::report(log_message, "User %d connected", _client.back()->getID());
} }
handleInput(); handleInput();
} }
} }