Skip to content

Commit

Permalink
lib-http: client: Created http_client_connection_failure() handler.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanbosch authored and sirainen committed Nov 9, 2016
1 parent d9c3269 commit 6324e0d
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/lib-http/http-client-connection.c
Expand Up @@ -48,6 +48,15 @@ http_client_connection_debug(struct http_client_connection *conn,
static void http_client_connection_ready(struct http_client_connection *conn);
static void http_client_connection_input(struct connection *_conn);

static inline void
http_client_connection_failure(struct http_client_connection *conn,
const char *reason)
{
struct http_client_peer *peer = conn->peer;

http_client_peer_connection_failure(peer, reason);
}

unsigned int
http_client_connection_count_pending(struct http_client_connection *conn)
{
Expand Down Expand Up @@ -531,7 +540,7 @@ static void http_client_connection_destroy(struct connection *_conn)
_conn->name, msecs/1000, msecs%1000);
}
http_client_connection_debug(conn, "%s", error);
http_client_peer_connection_failure(conn->peer, error);
http_client_connection_failure(conn, error);
break;
case CONNECTION_DISCONNECT_CONN_CLOSED:
/* retry pending requests if possible */
Expand Down Expand Up @@ -1226,7 +1235,7 @@ http_client_connection_connected(struct connection *_conn, bool success)
const char *error;

if (!success) {
http_client_peer_connection_failure(conn->peer, t_strdup_printf(
http_client_connection_failure(conn, t_strdup_printf(
"connect(%s) failed: %m", _conn->name));
} else {
conn->connected_timestamp = ioloop_timeval;
Expand All @@ -1247,8 +1256,8 @@ http_client_connection_connected(struct connection *_conn, bool success)

if (http_client_peer_addr_is_https(&conn->peer->addr)) {
if (http_client_connection_ssl_init(conn, &error) < 0) {
http_client_peer_connection_failure(conn->peer, error);
http_client_connection_debug(conn, "%s", error);
http_client_connection_failure(conn, error);
http_client_connection_close(&conn);
}
return;
Expand Down Expand Up @@ -1346,7 +1355,7 @@ http_client_connection_tunnel_response(const struct http_response *response,
conn->connect_request = NULL;

if (response->status != 200) {
http_client_peer_connection_failure(conn->peer, t_strdup_printf(
http_client_connection_failure(conn, t_strdup_printf(
"Tunnel connect(%s) failed: %d %s", name,
response->status, response->reason));
return;
Expand Down

0 comments on commit 6324e0d

Please sign in to comment.