Skip to content

Commit

Permalink
hotfix
Browse files Browse the repository at this point in the history
recreate socket on RESTART command
  • Loading branch information
levensta committed Oct 24, 2021
1 parent 9a92ebd commit 82079a7
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions conf/IRConf.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"servername": "IRCat",
"info": "IRC server based on TCP/IP protocol to rfc1459 standard",
"version": "v1.2",
"debuglvl": "0",
"debuglvl": "1",
"comments": "release",
"describe": "describe",
"adminName": "Nikita",
"adminNickname": "rmass",
"adminEmail": "[email protected]",
"allowedIP": "127.0.0.1",
"allowedIP": "0.0.0.0",
"maxChannels": 10,
"maxInactiveTimeout": 120,
"maxResponseTimeout": 60,
Expand Down
2 changes: 1 addition & 1 deletion srcs/Channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ void Channel::removeOperator(const User &user)
if (operators.size() == 0 && users.size() > 0)
{
operators.push_back(users[0]);
sendMessage("MODE " + this->name + " +o " + user.getNickname() + "\n", user, true);
sendMessage("MODE " + this->name + " +o " + users[0]->getNickname() + "\n", user, true);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions srcs/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ void Server::listenSocket()
std::cout << "Failed to listen on socket. errno: " << errno << std::endl;
exit(EXIT_FAILURE);
}
fcntl(sockfd, F_SETFL, O_NONBLOCK);
}

void Server::grabConnection()
Expand Down
9 changes: 9 additions & 0 deletions srcs/commands/ircOperatorCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,14 @@ int Server::restartCmd(const Message &msg, User &user) {
}

loadConfig();
close(sockfd);
// Create a socket (IPv4, TCP)
createSocket();

// Listen to port on any address
bindSocket();

// Start listening.
listenSocket();
return 0;
}
2 changes: 0 additions & 2 deletions srcs/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ int main(int argc, char **argv)
// Start listening.
server.listenSocket();

fcntl(server.getSockfd(), F_SETFL, O_NONBLOCK);

signal(SIGINT, sigHandler);

while (work)
Expand Down

0 comments on commit 82079a7

Please sign in to comment.