dovecot-2.1: login proxy: For connect() failures log also the us...
dovecot at dovecot.org
dovecot at dovecot.org
Mon Oct 29 19:04:52 EET 2012
details: http://hg.dovecot.org/dovecot-2.1/rev/9d63f882194d
changeset: 14791:9d63f882194d
user: Timo Sirainen <tss at iki.fi>
date: Mon Oct 29 19:04:36 2012 +0200
description:
login proxy: For connect() failures log also the used local IP:port if available.
diffstat:
src/login-common/login-proxy.c | 41 +++++++++++++++++++++++++++++------------
1 files changed, 29 insertions(+), 12 deletions(-)
diffs (74 lines):
diff -r 67e9cb0b06ec -r 9d63f882194d src/login-common/login-proxy.c
--- a/src/login-common/login-proxy.c Mon Oct 29 16:36:59 2012 +0200
+++ b/src/login-common/login-proxy.c Mon Oct 29 19:04:36 2012 +0200
@@ -5,6 +5,7 @@
#include "istream.h"
#include "ostream.h"
#include "llist.h"
+#include "str.h"
#include "str-sanitize.h"
#include "time-util.h"
#include "master-service.h"
@@ -194,16 +195,33 @@
proxy->state_rec = NULL;
}
+static void
+proxy_log_connect_error(struct login_proxy *proxy)
+{
+ string_t *str = t_str_new(128);
+ struct ip_addr local_ip;
+ unsigned int local_port;
+
+ str_printfa(str, "proxy(%s): connect(%s, %u) failed: %m (after %u secs",
+ proxy->client->virtual_user,
+ proxy->host, proxy->port,
+ (unsigned int)(ioloop_time - proxy->created.tv_sec));
+
+ if (proxy->server_fd != -1 &&
+ net_getsockname(proxy->server_fd, &local_ip, &local_port) == 0) {
+ str_printfa(str, ", local=%s:%u",
+ net_ip2addr(&local_ip), local_port);
+ }
+
+ str_append_c(str, ')');
+ i_error("%s", str_c(str));
+}
+
static void proxy_wait_connect(struct login_proxy *proxy)
{
- int err;
-
- err = net_geterror(proxy->server_fd);
- if (err != 0) {
- i_error("proxy(%s): connect(%s, %u) failed: %s (after %u secs)",
- proxy->client->virtual_user,
- proxy->host, proxy->port, strerror(err),
- (unsigned int)(ioloop_time - proxy->created.tv_sec));
+ errno = net_geterror(proxy->server_fd);
+ if (errno != 0) {
+ proxy_log_connect_error(proxy);
proxy_fail_connect(proxy);
login_proxy_free(&proxy);
return;
@@ -229,8 +247,8 @@
static void proxy_connect_timeout(struct login_proxy *proxy)
{
- i_error("proxy(%s): connect(%s, %u) timed out",
- proxy->client->virtual_user, proxy->host, proxy->port);
+ errno = ETIMEDOUT;
+ proxy_log_connect_error(proxy);
proxy_fail_connect(proxy);
login_proxy_free(&proxy);
}
@@ -252,8 +270,7 @@
proxy->server_fd = net_connect_ip(&proxy->ip, proxy->port, NULL);
if (proxy->server_fd == -1) {
- i_error("proxy(%s): connect(%s, %u) failed: %m",
- proxy->client->virtual_user, proxy->host, proxy->port);
+ proxy_log_connect_error(proxy);
login_proxy_free(&proxy);
return -1;
}
More information about the dovecot-cvs
mailing list