]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
director: If outgoing connection dies soon, mark the host as failed to avoid immediat...
authorTimo Sirainen <tss@iki.fi>
Thu, 2 Sep 2010 14:35:21 +0000 (15:35 +0100)
committerTimo Sirainen <tss@iki.fi>
Thu, 2 Sep 2010 14:35:21 +0000 (15:35 +0100)
src/director/director-connection.c

index 6e38e47ab1b7da53327d1e5011b9fd04d8bb7071..a37cb4c312140a82a472f784a06a495656fdc1c4 100644 (file)
 #define DIRECTOR_CONNECTION_PING_INTERVAL_MSECS (15*1000)
 /* How long to wait before sending PING while waiting for SYNC reply */
 #define DIRECTOR_CONNECTION_SYNC_TIMEOUT_MSECS 1000
+/* If outgoing director connection exists for less than this many seconds,
+   mark the host as failed so we won't try to reconnect to it immediately */
+#define DIRECTOR_SUCCESS_MIN_CONNECT_SECS 10
 
 struct director_connection {
        struct director_connection *prev, *next;
 
        struct director *dir;
        char *name;
+       time_t created;
 
        /* for incoming connections the director host isn't known until
           ME-line is received */
@@ -887,6 +891,7 @@ director_connection_init_common(struct director *dir, int fd)
        struct director_connection *conn;
 
        conn = i_new(struct director_connection, 1);
+       conn->created = ioloop_time;
        conn->fd = fd;
        conn->dir = dir;
        conn->input = i_stream_create_fd(conn->fd, MAX_INBUF_SIZE, FALSE);
@@ -991,6 +996,10 @@ void director_connection_deinit(struct director_connection **_conn)
 
        *_conn = NULL;
 
+       if (conn->host != NULL && !conn->in &&
+           conn->created + DIRECTOR_SUCCESS_MIN_CONNECT_SECS > ioloop_time)
+               conn->host->last_failed = ioloop_time;
+
        DLLIST_REMOVE(&dir->connections, conn);
        if (dir->left == conn)
                dir->left = NULL;