Skip to content

Commit 4605feb

Browse files
PettitWesleyEC2 Default User
authored and
EC2 Default User
committed
upstream_conn: clean up keepalive event in sync case
Resolves this issue: fluent#6821 Signed-off-by: Wesley Pettit <[email protected]>
1 parent a61abdd commit 4605feb

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

include/fluent-bit/flb_upstream_conn.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ struct flb_upstream_conn {
4646
/* Keepalive */
4747
int ka_count; /* how many times this connection has been used */
4848

49+
/* do we need to mk_event_del the keepalive event on clean up*/
50+
int ka_dropped_event_added;
51+
4952
/*
5053
* Custom 'error' for the connection file descriptor. Commonly used to
5154
* specify a reason for an exception that was generated locally: consider

src/flb_upstream.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ static int prepare_destroy_conn(struct flb_upstream_conn *u_conn)
429429
flb_trace("[upstream] destroy connection #%i to %s:%i",
430430
u_conn->fd, u->tcp_host, u->tcp_port);
431431

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

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

517+
conn->ka_dropped_event_added = FLB_FALSE;
518+
517519
/* retrieve the event loop */
518520
evl = flb_engine_evl_get();
519521
conn->evl = evl;
@@ -769,6 +771,7 @@ int flb_upstream_conn_release(struct flb_upstream_conn *conn)
769771
conn->fd, conn->u->tcp_host, conn->u->tcp_port);
770772
return prepare_destroy_conn_safe(conn);
771773
}
774+
conn->ka_dropped_event_added = FLB_TRUE;
772775

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

0 commit comments

Comments
 (0)