Skip to content

Commit

Permalink
upstream_conn: clean up keepalive event in sync case
Browse files Browse the repository at this point in the history
Resolves this issue: fluent#6821

Signed-off-by: Wesley Pettit <wppttt@amazon.com>
  • Loading branch information
PettitWesley authored and Swapneil Singh committed Oct 3, 2024
1 parent 69b0503 commit baa2e2c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions include/fluent-bit/flb_upstream_conn.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ struct flb_upstream_conn {
/* Keepalive */
int ka_count; /* how many times this connection has been used */

/* do we need to mk_event_del the keepalive event on clean up*/
int ka_dropped_event_added;

/*
* Custom 'error' for the connection file descriptor. Commonly used to
* specify a reason for an exception that was generated locally: consider
Expand Down
5 changes: 4 additions & 1 deletion src/flb_upstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ static int prepare_destroy_conn(struct flb_upstream_conn *u_conn)
flb_trace("[upstream] destroy connection #%i to %s:%i",
u_conn->fd, u->tcp_host, u->tcp_port);

if (u->flags & FLB_IO_ASYNC) {
if (u->flags & FLB_IO_ASYNC || u_conn->ka_dropped_event_added == FLB_TRUE) {
mk_event_del(u_conn->evl, &u_conn->event);
}

Expand Down Expand Up @@ -514,6 +514,8 @@ static struct flb_upstream_conn *create_conn(struct flb_upstream *u)
conn->net_error = -1;
conn->busy_flag = FLB_TRUE;

conn->ka_dropped_event_added = FLB_FALSE;

/* retrieve the event loop */
evl = flb_engine_evl_get();
conn->evl = evl;
Expand Down Expand Up @@ -769,6 +771,7 @@ int flb_upstream_conn_release(struct flb_upstream_conn *conn)
conn->fd, conn->u->tcp_host, conn->u->tcp_port);
return prepare_destroy_conn_safe(conn);
}
conn->ka_dropped_event_added = FLB_TRUE;

flb_debug("[upstream] KA connection #%i to %s:%i is now available",
conn->fd, conn->u->tcp_host, conn->u->tcp_port);
Expand Down

0 comments on commit baa2e2c

Please sign in to comment.