Skip to content

Commit 8ccc7bf

Browse files
PettitWesleyedsiper
authored andcommitted
upstream_conn: fix ordering of mk_event_inject and prepare_conn_destroy
prepare_destroy_conn calls mk_list_del on the event in the priority bucket queue, so for safety, we inject it after this covers us against the case where the event was triggered and waiting, but we also reached the timeout. Signed-off-by: Wesley Pettit <wppttt@amazon.com>
1 parent c0fc037 commit 8ccc7bf

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/flb_upstream.c

+11-2
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,7 @@ int flb_upstream_conn_timeouts(struct mk_list *list)
794794
{
795795
time_t now;
796796
int drop;
797+
int inject;
797798
struct mk_list *head;
798799
struct mk_list *u_head;
799800
struct mk_list *tmp;
@@ -842,13 +843,21 @@ int flb_upstream_conn_timeouts(struct mk_list *list)
842843
}
843844

844845
if (drop == FLB_TRUE) {
846+
inject = FLB_FALSE;
845847
if (u_conn->event.status != MK_EVENT_NONE) {
848+
inject = FLB_TRUE;
849+
}
850+
u_conn->net_error = ETIMEDOUT;
851+
prepare_destroy_conn(u_conn);
852+
/*
853+
* prepare_destroy_conn calls mk_list_del on the event in the
854+
* priority bucket queue, so for safety, we inject it afterwards
855+
*/
856+
if (inject == FLB_TRUE) {
846857
mk_event_inject(u_conn->evl, &u_conn->event,
847858
MK_EVENT_READ | MK_EVENT_WRITE,
848859
FLB_TRUE);
849860
}
850-
u_conn->net_error = ETIMEDOUT;
851-
prepare_destroy_conn(u_conn);
852861
}
853862
}
854863

0 commit comments

Comments
 (0)