diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2010-10-08 18:31:17 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2010-10-08 18:31:17 +0200 |
commit | 6e89c47bf1237c9b94125663b1373212105659d1 (patch) | |
tree | 3a04f8fd310de6eba5d9a471ccea8c014b7c115f /src | |
parent | 321210ff6e597bab9790b158cd860f60f5fdcfc6 (diff) | |
download | weechat-6e89c47bf1237c9b94125663b1373212105659d1.zip |
Switch to next server address when IRC error is received after TCP connection but before message 001 (bug #30884)
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/irc/irc-buffer.c | 2 | ||||
-rw-r--r-- | src/plugins/irc/irc-command.c | 4 | ||||
-rw-r--r-- | src/plugins/irc/irc-protocol.c | 12 | ||||
-rw-r--r-- | src/plugins/irc/irc-server.c | 53 | ||||
-rw-r--r-- | src/plugins/irc/irc-server.h | 3 | ||||
-rw-r--r-- | src/plugins/irc/irc.c | 2 |
6 files changed, 45 insertions, 31 deletions
diff --git a/src/plugins/irc/irc-buffer.c b/src/plugins/irc/irc-buffer.c index 8cc9edac4..da214932b 100644 --- a/src/plugins/irc/irc-buffer.c +++ b/src/plugins/irc/irc-buffer.c @@ -151,7 +151,7 @@ irc_buffer_close_cb (void *data, struct t_gui_buffer *buffer) weechat_buffer_close (ptr_channel->buffer); ptr_channel = next_channel; } - irc_server_disconnect (ptr_server, 0); + irc_server_disconnect (ptr_server, 0, 0); ptr_server->buffer = NULL; } } diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c index b8db9e36b..a1af1ea81 100644 --- a/src/plugins/irc/irc-command.c +++ b/src/plugins/irc/irc-command.c @@ -1322,7 +1322,7 @@ irc_command_disconnect_one_server (struct t_irc_server *server) IRC_PLUGIN_NAME); } irc_command_quit_server (server, NULL); - irc_server_disconnect (server, 0); + irc_server_disconnect (server, 0, 0); /* disconnect ok */ return 1; @@ -2985,7 +2985,7 @@ irc_command_reconnect_one_server (struct t_irc_server *server, int no_join) return 0; } irc_command_quit_server (server, NULL); - irc_server_disconnect (server, 0); + irc_server_disconnect (server, 0, 0); server->disable_autojoin = no_join; if (irc_server_connect (server)) { diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index 215acd97a..88d6cc2d8 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -474,7 +474,9 @@ IRC_PROTOCOL_CALLBACK(error) ptr_args); if (strncmp (ptr_args, "Closing Link", 12) == 0) - irc_server_disconnect (server, 1); + { + irc_server_disconnect (server, !server->is_connected, 1); + } return WEECHAT_RC_OK; } @@ -491,7 +493,7 @@ IRC_PROTOCOL_CALLBACK(generic_error) struct t_irc_channel *ptr_channel; /* - * Example of error: + * example of error: * :server 404 nick #channel :Cannot send to channel */ @@ -3910,7 +3912,7 @@ IRC_PROTOCOL_CALLBACK(432) "connection with server"), weechat_prefix ("error"), IRC_PLUGIN_NAME); - irc_server_disconnect (server, 1); + irc_server_disconnect (server, 0, 1); return WEECHAT_RC_OK; } @@ -3962,7 +3964,7 @@ IRC_PROTOCOL_CALLBACK(433) "connection with server"), weechat_prefix ("error"), IRC_PLUGIN_NAME); - irc_server_disconnect (server, 1); + irc_server_disconnect (server, 0, 1); return WEECHAT_RC_OK; } @@ -4026,7 +4028,7 @@ IRC_PROTOCOL_CALLBACK(437) "connection with server"), weechat_prefix ("error"), IRC_PLUGIN_NAME); - irc_server_disconnect (server, 1); + irc_server_disconnect (server, 0, 1); return WEECHAT_RC_OK; } diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c index 019987e3d..bf77325c2 100644 --- a/src/plugins/irc/irc-server.c +++ b/src/plugins/irc/irc-server.c @@ -1997,7 +1997,7 @@ irc_server_recv_cb (void *data, int fd) weechat_printf (server->buffer, _("%s: disconnecting from server..."), IRC_PLUGIN_NAME); - irc_server_disconnect (server, 1); + irc_server_disconnect (server, !server->is_connected, 1); } } else @@ -2015,7 +2015,7 @@ irc_server_recv_cb (void *data, int fd) weechat_printf (server->buffer, _("%s: disconnecting from server..."), IRC_PLUGIN_NAME); - irc_server_disconnect (server, 1); + irc_server_disconnect (server, !server->is_connected, 1); } } } @@ -2049,7 +2049,7 @@ irc_server_timer_connection_cb (void *data, int remaining_calls) weechat_printf (server->buffer, _("%s%s: connection timeout (message 001 not received)"), weechat_prefix ("error"), IRC_PLUGIN_NAME); - irc_server_disconnect (server, 1); + irc_server_disconnect (server, !server->is_connected, 1); } return WEECHAT_RC_OK; @@ -2169,7 +2169,7 @@ irc_server_timer_cb (void *data, int remaining_calls) _("%s: lag is high, disconnecting " "from server..."), IRC_PLUGIN_NAME); - irc_server_disconnect (ptr_server, 1); + irc_server_disconnect (ptr_server, 0, 1); } } } @@ -2277,8 +2277,6 @@ irc_server_reconnect_schedule (struct t_irc_server *server) { int minutes, seconds; - irc_server_set_index_current_address (server, 0); - if (IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_AUTORECONNECT)) { /* growing reconnect delay */ @@ -2382,21 +2380,30 @@ irc_server_login (struct t_irc_server *server) */ void -irc_server_switch_address (struct t_irc_server *server) +irc_server_switch_address (struct t_irc_server *server, int connection) { - if ((server->addresses_count > 1) - && (server->index_current_address < server->addresses_count - 1)) + if (server->addresses_count > 1) { - irc_server_set_index_current_address (server, server->index_current_address + 1); + irc_server_set_index_current_address (server, + (server->index_current_address + 1) % server->addresses_count); weechat_printf (server->buffer, _("%s: switching address to %s/%d"), IRC_PLUGIN_NAME, server->current_address, server->current_port); - irc_server_connect (server); + if (connection) + { + if (server->index_current_address == 0) + irc_server_reconnect_schedule (server); + else + irc_server_connect (server); + } } else - irc_server_reconnect_schedule (server); + { + if (connection) + irc_server_reconnect_schedule (server); + } } /* @@ -2450,7 +2457,7 @@ irc_server_connect_cb (void *data, int status, int gnutls_rc, error); } irc_server_close_connection (server); - irc_server_switch_address (server); + irc_server_switch_address (server, 1); break; case WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND: weechat_printf (server->buffer, @@ -2466,7 +2473,7 @@ irc_server_connect_cb (void *data, int status, int gnutls_rc, error); } irc_server_close_connection (server); - irc_server_switch_address (server); + irc_server_switch_address (server, 1); break; case WEECHAT_HOOK_CONNECT_CONNECTION_REFUSED: weechat_printf (server->buffer, @@ -2482,7 +2489,7 @@ irc_server_connect_cb (void *data, int status, int gnutls_rc, error); } irc_server_close_connection (server); - irc_server_switch_address (server); + irc_server_switch_address (server, 1); break; case WEECHAT_HOOK_CONNECT_PROXY_ERROR: weechat_printf (server->buffer, @@ -2500,7 +2507,7 @@ irc_server_connect_cb (void *data, int status, int gnutls_rc, error); } irc_server_close_connection (server); - irc_server_switch_address (server); + irc_server_switch_address (server, 1); break; case WEECHAT_HOOK_CONNECT_LOCAL_HOSTNAME_ERROR: weechat_printf (server->buffer, @@ -2557,7 +2564,7 @@ irc_server_connect_cb (void *data, int status, int gnutls_rc, (void) gnutls_rc; #endif irc_server_close_connection (server); - irc_server_switch_address (server); + irc_server_switch_address (server, 1); break; case WEECHAT_HOOK_CONNECT_MEMORY_ERROR: weechat_printf (server->buffer, @@ -3182,7 +3189,6 @@ irc_server_reconnect (struct t_irc_server *server) IRC_PLUGIN_NAME); server->reconnect_start = 0; - irc_server_set_index_current_address(server, 0); if (irc_server_connect (server)) server->reconnect_join = 1; @@ -3215,7 +3221,8 @@ irc_server_auto_connect () */ void -irc_server_disconnect (struct t_irc_server *server, int reconnect) +irc_server_disconnect (struct t_irc_server *server, int switch_address, + int reconnect) { struct t_irc_channel *ptr_channel; @@ -3245,7 +3252,11 @@ irc_server_disconnect (struct t_irc_server *server, int reconnect) IRC_PLUGIN_NAME); } - irc_server_set_index_current_address(server, 0); + if (switch_address) + irc_server_switch_address (server, 0); + else + irc_server_set_index_current_address(server, 0); + if (server->nick_modes) { free (server->nick_modes); @@ -3303,7 +3314,7 @@ irc_server_disconnect_all () for (ptr_server = irc_servers; ptr_server; ptr_server = ptr_server->next_server) { - irc_server_disconnect (ptr_server, 0); + irc_server_disconnect (ptr_server, 0, 0); } } diff --git a/src/plugins/irc/irc-server.h b/src/plugins/irc/irc-server.h index e71294722..7d4400970 100644 --- a/src/plugins/irc/irc-server.h +++ b/src/plugins/irc/irc-server.h @@ -232,7 +232,8 @@ extern void irc_server_set_away (struct t_irc_server *server, const char *nick, int is_away); extern void irc_server_remove_away (); extern void irc_server_check_away (); -extern void irc_server_disconnect (struct t_irc_server *server, int reconnect); +extern void irc_server_disconnect (struct t_irc_server *server, + int switch_address, int reconnect); extern void irc_server_disconnect_all (); extern void irc_server_free (struct t_irc_server *server); extern int irc_server_xfer_send_ready_cb (void *data, const char *signal, diff --git a/src/plugins/irc/irc.c b/src/plugins/irc/irc.c index 6e7ba0dab..489f9f651 100644 --- a/src/plugins/irc/irc.c +++ b/src/plugins/irc/irc.c @@ -120,7 +120,7 @@ irc_signal_upgrade_cb (void *data, const char *signal, const char *type_data, "can't work for servers connected via SSL"), weechat_prefix ("error"), IRC_PLUGIN_NAME); - irc_server_disconnect (ptr_server, 0); + irc_server_disconnect (ptr_server, 0, 0); /* * schedule reconnection: WeeChat will reconnect to this server * after restart |