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);
/* 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;
/* 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);
{
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)
{
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)
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;
unsigned int pending_requests;
};
+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)
{
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);