]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
doveadm: When connecting to doveadm-server via TCP, use 30s timeout
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 12 Dec 2016 10:51:42 +0000 (12:51 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 12 Dec 2016 10:55:36 +0000 (12:55 +0200)
Should be enough, and better than the kernel's default, which might be a lot
more.

src/doveadm/doveadm-util.c

index bef804a472e37d96dfed56988710d1c90ddc4a39..3a895f5af479bed006910d72df7b2815bdbb8f8a 100644 (file)
@@ -15,6 +15,8 @@
 #include <sys/stat.h>
 #include <ctype.h>
 
+#define DOVEADM_TCP_CONNECT_TIMEOUT_SECS 30
+
 bool doveadm_verbose = FALSE, doveadm_debug = FALSE, doveadm_server = FALSE;
 static struct module *modules = NULL;
 
@@ -104,6 +106,7 @@ doveadm_tcp_connect_port(const char *host, in_port_t port)
        unsigned int ips_count;
        int ret, fd;
 
+       alarm(DOVEADM_TCP_CONNECT_TIMEOUT_SECS);
        ret = net_gethostbyname(host, &ips, &ips_count);
        if (ret != 0) {
                i_fatal("Lookup of host %s failed: %s",
@@ -114,6 +117,7 @@ doveadm_tcp_connect_port(const char *host, in_port_t port)
                i_fatal("connect(%s:%u) failed: %m",
                        net_ip2addr(&ips[0]), port);
        }
+       alarm(0);
        return fd;
 }