Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upstream_conn: clean up keepalive event in sync case #6844

Open
wants to merge 1 commit into
base: 1.9
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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