dovecot-2.2: lib-http: Fixed client connection and peer log labe...
dovecot at dovecot.org
dovecot at dovecot.org
Sun Sep 15 03:38:25 EEST 2013
details: http://hg.dovecot.org/dovecot-2.2/rev/bb6506d2d084
changeset: 16736:bb6506d2d084
user: Stephan Bosch <stephan at rename-it.nl>
date: Sun Sep 15 03:33:04 2013 +0300
description:
lib-http: Fixed client connection and peer log labels to show proper IPv6 peers.
The labels did not put IPv6 addresses in square brackets.
diffstat:
src/lib-http/http-client-host.c | 29 ++++++++++++++---------------
src/lib-http/http-client-peer.c | 5 ++---
src/lib-http/http-client-private.h | 18 ++++++++++++++++--
3 files changed, 32 insertions(+), 20 deletions(-)
diffs (125 lines):
diff -r 9af78d53e22f -r bb6506d2d084 src/lib-http/http-client-host.c
--- a/src/lib-http/http-client-host.c Sun Sep 15 03:32:11 2013 +0300
+++ b/src/lib-http/http-client-host.c Sun Sep 15 03:33:04 2013 +0300
@@ -134,6 +134,7 @@
http_client_host_port_soft_connect_timeout(struct http_client_host_port *hport)
{
struct http_client_host *host = hport->host;
+ const struct http_client_peer_addr *addr = &hport->addr;
if (hport->to_connect != NULL)
timeout_remove(&hport->to_connect);
@@ -146,12 +147,10 @@
/* if our our previous connection attempt takes longer than the
soft_connect_timeout, we start a connection attempt to the next IP in
parallel */
-
- http_client_host_debug(host, "Connection to %s:%u%s is taking a long time; "
+ http_client_host_debug(host, "Connection to %s%s is taking a long time; "
"starting parallel connection attempt to next IP",
- net_ip2addr(&hport->addr.ip), hport->addr.port,
- hport->addr.https_name == NULL ? "" :
- t_strdup_printf(" (SSL=%s)", hport->addr.https_name));
+ http_client_peer_addr2str(addr), addr->https_name == NULL ? "" :
+ t_strdup_printf(" (SSL=%s)", addr->https_name));
/* next IP */
hport->ips_connect_idx = (hport->ips_connect_idx + 1) % host->ips_count;
@@ -174,10 +173,10 @@
/* update our peer address */
hport->addr.ip = host->ips[hport->ips_connect_idx];
- http_client_host_debug(host, "Setting up connection to %s:%u%s "
- "(%u requests pending)", net_ip2addr(&addr->ip), addr->port,
- addr->https_name == NULL ? "" :
- t_strdup_printf(" (SSL=%s)", addr->https_name), num_requests);
+ http_client_host_debug(host, "Setting up connection to %s%s "
+ "(%u requests pending)", http_client_peer_addr2str(addr),
+ (addr->https_name == NULL ? "" :
+ t_strdup_printf(" (SSL=%s)", addr->https_name)), num_requests);
/* create/get peer */
peer = http_client_peer_get(host->client, addr);
@@ -307,8 +306,8 @@
{
struct http_client_host_port *hport;
- http_client_host_debug(host, "Successfully connected to %s:%u",
- net_ip2addr(&addr->ip), addr->port);
+ http_client_host_debug(host, "Successfully connected to %s",
+ http_client_peer_addr2str(addr));
hport = http_client_host_port_find(host, addr->port, addr->https_name);
if (hport == NULL)
@@ -322,8 +321,8 @@
{
struct http_client_host_port *hport;
- http_client_host_debug(host, "Failed to connect to %s:%u: %s",
- net_ip2addr(&addr->ip), addr->port, reason);
+ http_client_host_debug(host, "Failed to connect to %s: %s",
+ http_client_peer_addr2str(addr), reason);
hport = http_client_host_port_find(host, addr->port, addr->https_name);
if (hport == NULL)
@@ -513,8 +512,8 @@
array_delete(&hport->request_queue, i, 1);
http_client_host_debug(host,
- "Connection to peer %s:%u claimed request %s %s",
- net_ip2addr(&addr->ip), addr->port, http_client_request_label(req),
+ "Connection to peer %s claimed request %s %s",
+ http_client_peer_addr2str(addr), http_client_request_label(req),
(req->urgent ? "(urgent)" : ""));
return req;
diff -r 9af78d53e22f -r bb6506d2d084 src/lib-http/http-client-peer.c
--- a/src/lib-http/http-client-peer.c Sun Sep 15 03:32:11 2013 +0300
+++ b/src/lib-http/http-client-peer.c Sun Sep 15 03:33:04 2013 +0300
@@ -29,9 +29,8 @@
if (peer->client->set.debug) {
va_start(args, format);
- i_debug("http-client: peer %s:%u: %s",
- net_ip2addr(&peer->addr.ip), peer->addr.port,
- t_strdup_vprintf(format, args));
+ i_debug("http-client: peer %s: %s",
+ http_client_peer_label(peer), t_strdup_vprintf(format, args));
va_end(args);
}
}
diff -r 9af78d53e22f -r bb6506d2d084 src/lib-http/http-client-private.h
--- a/src/lib-http/http-client-private.h Sun Sep 15 03:32:11 2013 +0300
+++ b/src/lib-http/http-client-private.h Sun Sep 15 03:33:04 2013 +0300
@@ -190,6 +190,14 @@
};
static inline const char *
+http_client_peer_addr2str(const struct http_client_peer_addr *addr)
+{
+ if (addr->ip.family == AF_INET6)
+ return t_strdup_printf("[%s]:%u", net_ip2addr(&addr->ip), addr->port);
+ return t_strdup_printf("%s:%u", net_ip2addr(&addr->ip), addr->port);
+}
+
+static inline const char *
http_client_request_label(struct http_client_request *req)
{
return t_strdup_printf("[%s http%s://%s:%d%s]",
@@ -199,8 +207,14 @@
static inline const char *
http_client_connection_label(struct http_client_connection *conn)
{
- return t_strdup_printf("%s:%u [%d]",
- net_ip2addr(&conn->conn.ip), conn->conn.port, conn->id);
+ return t_strdup_printf("%s [%d]",
+ http_client_peer_addr2str(&conn->peer->addr), conn->id);
+}
+
+static inline const char *
+http_client_peer_label(struct http_client_peer *peer)
+{
+ return http_client_peer_addr2str(&peer->addr);
}
int http_client_init_ssl_ctx(struct http_client *client, const char **error_r);
More information about the dovecot-cvs
mailing list