Mercurial > dovecot > core-2.2
changeset 22250:81a74bce2b07
director: Fix handshake timeout lengths
They weren't too bad, but also they weren't what the #defines described.
Also added a separate connect() timeout.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Wed, 31 May 2017 13:11:08 +0300 |
parents | f65e7542dd4f |
children | dce18ed41532 |
files | src/director/director-connection.c |
diffstat | 1 files changed, 14 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/director/director-connection.c Sat Jun 17 14:39:59 2017 +0300 +++ b/src/director/director-connection.c Wed May 31 13:11:08 2017 +0300 @@ -49,6 +49,8 @@ #define MAX_INBUF_SIZE 1024 #define MAX_OUTBUF_SIZE (1024*1024*10) #define OUTBUF_FLUSH_THRESHOLD (1024*128) +/* Max time to wait for connect() to finish before aborting */ +#define DIRECTOR_CONNECTION_CONNECT_TIMEOUT_MSECS (10*1000) /* Max idling time before "ME" command must have been received, or we'll disconnect. */ #define DIRECTOR_CONNECTION_ME_TIMEOUT_MSECS (10*1000) @@ -428,8 +430,13 @@ } timeout_remove(&conn->to_ping); - conn->to_ping = timeout_add(DIRECTOR_CONNECTION_DONE_TIMEOUT_MSECS, - director_connection_init_timeout, conn); + if (conn->in) { + conn->to_ping = timeout_add(DIRECTOR_CONNECTION_DONE_TIMEOUT_MSECS, + director_connection_init_timeout, conn); + } else { + conn->to_ping = timeout_add(DIRECTOR_CONNECTION_SEND_USERS_TIMEOUT_MSECS, + director_connection_init_timeout, conn); + } if (!conn->in) return TRUE; @@ -1949,8 +1956,6 @@ conn->input = i_stream_create_fd(conn->fd, MAX_INBUF_SIZE, FALSE); conn->output = o_stream_create_fd(conn->fd, MAX_OUTBUF_SIZE, FALSE); o_stream_set_no_error_handling(conn->output, TRUE); - conn->to_ping = timeout_add(DIRECTOR_CONNECTION_ME_TIMEOUT_MSECS, - director_connection_init_timeout, conn); array_append(&dir->connections, &conn, 1); return conn; } @@ -1976,6 +1981,8 @@ conn->connected = TRUE; conn->name = i_strdup_printf("%s/in", net_ip2addr(ip)); conn->io = io_add(conn->fd, IO_READ, director_connection_input, conn); + conn->to_ping = timeout_add(DIRECTOR_CONNECTION_ME_TIMEOUT_MSECS, + director_connection_init_timeout, conn); director_connection_send_handshake(conn); return conn; @@ -1999,7 +2006,7 @@ conn->io = io_add(conn->fd, IO_READ, director_connection_input, conn); timeout_remove(&conn->to_ping); - conn->to_ping = timeout_add(DIRECTOR_CONNECTION_SEND_USERS_TIMEOUT_MSECS, + conn->to_ping = timeout_add(DIRECTOR_CONNECTION_ME_TIMEOUT_MSECS, director_connection_init_timeout, conn); o_stream_cork(conn->output); @@ -2046,6 +2053,8 @@ director_host_ref(host); conn->io = io_add(conn->fd, IO_WRITE, director_connection_connected, conn); + conn->to_ping = timeout_add(DIRECTOR_CONNECTION_CONNECT_TIMEOUT_MSECS, + director_connection_init_timeout, conn); return conn; }