Mercurial > irccd
changeset 22:23d59afec277
Irccd: fix server.reconnect-tries, #417
author | David Demelier <markand@malikania.fr> |
---|---|
date | Fri, 12 Feb 2016 21:02:28 +0100 |
parents | 0357a728f8f8 |
children | 03068f5ed79d |
files | doc/html/guide/04-irccd/01-config.md doc/man/irccd.conf.5.in irccd/server-state.cpp irccd/server.h |
diffstat | 4 files changed, 10 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/html/guide/04-irccd/01-config.md Fri Feb 12 20:36:19 2016 +0100 +++ b/doc/html/guide/04-irccd/01-config.md Fri Feb 12 21:02:28 2016 +0100 @@ -121,7 +121,7 @@ - **ssl**: (bool) enable or disable SSL (Optional, default: false), - **ssl-verify**: (bool) verify the SSL certificates (Optional, default: true), - **reconnect**: (bool) enable reconnection after failure (Optional, default: true), - - **reconnect-tries**: (int) number of tries before giving up. A value of 0 means indefinitely (Optional, default: 0), + - **reconnect-tries**: (int) number of tries before giving up. A value of -1 means indefinitely (Optional, default: -1), - **reconnect-timeout**: (int) number of seconds to wait before retrying (Optional, default: 30). <div class="alert alert-info" role="alert">
--- a/doc/man/irccd.conf.5.in Fri Feb 12 20:36:19 2016 +0100 +++ b/doc/man/irccd.conf.5.in Fri Feb 12 21:02:28 2016 +0100 @@ -130,7 +130,7 @@ .It reconnect (bool) enable reconnection after failure (Optional, default: true). .It reconnect-tries -(int) number of tries before giving up. A value of 0 means indefinitely (Optional, default: 0). +(int) number of tries before giving up. A value of -1 means indefinitely (Optional, default: -1). .It reconnect-timeout (int) number of seconds to wait before retrying (Optional, default: 30). .El
--- a/irccd/server-state.cpp Fri Feb 12 20:36:19 2016 +0100 +++ b/irccd/server-state.cpp Fri Feb 12 21:02:28 2016 +0100 @@ -90,10 +90,8 @@ * It returns success if the connection was successful but it does not * mean that connection is established. * - * Because this function will be called repeatidly from the - * ServerManager, if the connection was started and we're still not - * connected in the specified timeout time, we mark the server - * as disconnected. + * Because this function will be called repeatidly, the connection was started and we're still not + * connected in the specified timeout time, we mark the server as disconnected. * * Otherwise, the libircclient event_connect will change the state. */ @@ -106,12 +104,11 @@ log::warning() << "server " << info.name << ": timeout while connecting" << std::endl; server.next(ServerState::Disconnected); } else if (!irc_is_connected(server.session())) { - log::warning() << "server " << info.name << ": error while connecting: " - << irc_strerror(irc_errno(server.session())) << std::endl; + log::warning() << "server " << info.name << ": error while connecting: "; + log::warning() << irc_strerror(irc_errno(server.session())) << std::endl; - if (settings.recotimeout > 0) { + if (settings.recotries != 0) log::warning() << "server " << info.name << ": retrying in " << settings.recotimeout << " seconds" << std::endl; - } server.next(ServerState::Disconnected); } else { @@ -144,11 +141,10 @@ const ServerInfo &info = server.info(); ServerSettings &settings = server.settings(); - /* if ServerSettings::recotries it set to -1, reconnection is completely disabled. */ - if (settings.recotries < 0) { + if (settings.recotries == 0) { log::warning() << "server " << info.name << ": reconnection disabled, skipping" << std::endl; server.onDie(); - } else if ((settings.recocurrent + 1) > settings.recotries) { + } else if (settings.recotries > 0 && settings.recocurrent > settings.recotries) { log::warning() << "server " << info.name << ": giving up" << std::endl; server.onDie(); } else {
--- a/irccd/server.h Fri Feb 12 20:36:19 2016 +0100 +++ b/irccd/server.h Fri Feb 12 21:02:28 2016 +0100 @@ -140,7 +140,7 @@ ServerChannels channels; //!< List of channel to join std::string command{"!"}; //!< The command character to trigger plugin command - std::int8_t recotries{3}; //!< Number of tries to reconnect before giving up + std::int8_t recotries{-1}; //!< Number of tries to reconnect before giving up std::uint16_t recotimeout{30}; //!< Number of seconds to wait before trying to connect std::uint8_t flags{0}; //!< Optional flags