Skip to content

Commit

Permalink
upstream_conn: fix ordering of mk_event_inject and prepare_conn_destroy
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
PettitWesley authored and edsiper committed Sep 26, 2024
1 parent c0fc037 commit 8ccc7bf
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/flb_upstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,7 @@ int flb_upstream_conn_timeouts(struct mk_list *list)
{
time_t now;
int drop;
int inject;
struct mk_list *head;
struct mk_list *u_head;
struct mk_list *tmp;
Expand Down Expand Up @@ -842,13 +843,21 @@ int flb_upstream_conn_timeouts(struct mk_list *list)
}

if (drop == FLB_TRUE) {
inject = FLB_FALSE;
if (u_conn->event.status != MK_EVENT_NONE) {
inject = FLB_TRUE;
}
u_conn->net_error = ETIMEDOUT;
prepare_destroy_conn(u_conn);
/*
* prepare_destroy_conn calls mk_list_del on the event in the
* priority bucket queue, so for safety, we inject it afterwards
*/
if (inject == FLB_TRUE) {
mk_event_inject(u_conn->evl, &u_conn->event,
MK_EVENT_READ | MK_EVENT_WRITE,
FLB_TRUE);
}
u_conn->net_error = ETIMEDOUT;
prepare_destroy_conn(u_conn);
}
}

Expand Down

0 comments on commit 8ccc7bf

Please sign in to comment.