Skip to content

Commit

Permalink
upstream: added code to discard failed connections
Browse files Browse the repository at this point in the history
Signed-off-by: Leonardo Alminana <[email protected]>
  • Loading branch information
leonardo-albertovich authored and edsiper committed Aug 31, 2023
1 parent afaa6da commit f0e9275
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/flb_upstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,9 +726,6 @@ struct flb_connection *flb_upstream_conn_get(struct flb_upstream *u)

flb_stream_release_lock(&u->base);

/* Reset errno */
conn->net_error = -1;

err = flb_socket_error(conn->fd);

if (!FLB_EINPROGRESS(err) && err != 0) {
Expand All @@ -740,6 +737,9 @@ struct flb_connection *flb_upstream_conn_get(struct flb_upstream *u)
continue;
}

/* Reset errno */
conn->net_error = -1;

/* Connect timeout */
conn->ts_assigned = time(NULL);
flb_debug("[upstream] KA connection #%i to %s:%i has been assigned (recycled)",
Expand Down Expand Up @@ -803,7 +803,8 @@ int flb_upstream_conn_release(struct flb_connection *conn)
/* If this is a valid KA connection just recycle */
if (u->base.net.keepalive == FLB_TRUE &&
conn->recycle == FLB_TRUE &&
conn->fd > -1) {
conn->fd > -1 &&
conn->net_error == -1) {
/*
* This connection is still useful, move it to the 'available' queue and
* initialize variables.
Expand Down

0 comments on commit f0e9275

Please sign in to comment.