summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2002-11-19 11:55:36 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2002-11-19 11:55:36 +0000
commite4accf9c80c961dcc99e08b859271e6c43fbe7b0 (patch)
tree67eb052f562c360c7ce645ef3332f84619970743
parent154d25f26076adcb38d890526f92a83586e585fe (diff)
downloadirssi-e4accf9c80c961dcc99e08b859271e6c43fbe7b0.zip
Timeout server connections if they're not in fully connected stage in /SET
server_connect_timeout seconds. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3013 dbcabf3a-b0e7-0310-adc4-f8d773084564
-rw-r--r--src/core/servers-reconnect.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/core/servers-reconnect.c b/src/core/servers-reconnect.c
index cc053150..c7b5dd45 100644
--- a/src/core/servers-reconnect.c
+++ b/src/core/servers-reconnect.c
@@ -34,6 +34,7 @@ GSList *reconnects;
static int last_reconnect_tag;
static int reconnect_timeout_tag;
static int reconnect_time;
+static int connect_timeout;
void reconnect_save_status(SERVER_CONNECT_REC *conn, SERVER_REC *server)
{
@@ -92,14 +93,28 @@ void server_reconnect_destroy(RECONNECT_REC *rec)
static int server_reconnect_timeout(void)
{
SERVER_CONNECT_REC *conn;
- GSList *list, *tmp;
+ GSList *list, *tmp, *next;
time_t now;
+ now = time(NULL);
+
+ /* timeout any connections that haven't gotten to connected-stage */
+ for (tmp = servers; tmp != NULL; tmp = next) {
+ SERVER_REC *server = tmp->data;
+
+ next = tmp->next;
+ if (!server->connected &&
+ server->connect_time + connect_timeout < now &&
+ connect_timeout > 0) {
+ server->connection_lost = TRUE;
+ server_disconnect(server);
+ }
+ }
+
/* If server_connect() removes the next reconnection in queue,
we're screwed. I don't think this should happen anymore, but just
to be sure we don't crash, do this safely. */
list = g_slist_copy(reconnects);
- now = time(NULL);
for (tmp = list; tmp != NULL; tmp = tmp->next) {
RECONNECT_REC *rec = tmp->data;
@@ -447,11 +462,13 @@ static void sig_chat_protocol_deinit(CHAT_PROTOCOL_REC *proto)
static void read_settings(void)
{
reconnect_time = settings_get_int("server_reconnect_time");
+ connect_timeout = settings_get_int("server_connect_timeout");
}
void servers_reconnect_init(void)
{
settings_add_int("server", "server_reconnect_time", 300);
+ settings_add_int("server", "server_connect_timeout", 300);
reconnects = NULL;
last_reconnect_tag = 0;