Skip to content

Commit

Permalink
doveadm: When connecting to doveadm-server via TCP, use 30s timeout
Browse files Browse the repository at this point in the history
Should be enough, and better than the kernel's default, which might be a lot
more.
  • Loading branch information
sirainen committed Dec 12, 2016
1 parent 271b814 commit 530b590
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/doveadm/doveadm-util.c
Expand Up @@ -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;

Expand Down Expand Up @@ -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",
Expand All @@ -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;
}

Expand Down

0 comments on commit 530b590

Please sign in to comment.