Skip to content

Commit

Permalink
network: detect if socket has been invalidated
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Silva <[email protected]>
  • Loading branch information
edsiper committed Nov 23, 2021
1 parent 6f3afc2 commit 8e1e565
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/flb_network.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,16 @@ static int net_connect_async(int fd,
/* Save the mask before the event handler do a reset */
mask = u_conn->event.mask;

/*
* If the socket has been invalidated (e.g: timeout or shutdown), just
* print a debug message and return.
*/
if (u_conn->fd == -1) {
flb_debug("[net] TCP connection not longer available: %s:%i",
u->tcp_host, u->tcp_port);
return -1;
}

/* We got a notification, remove the event registered */
ret = mk_event_del(u_conn->evl, &u_conn->event);
if (ret == -1) {
Expand Down

0 comments on commit 8e1e565

Please sign in to comment.