From 28851b2cdf92bfa92b2a92fe3dd6b58f39bb03cd Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Sat, 6 May 2017 01:20:17 -0400 Subject: [PATCH] [core] skip socket shutdown() if con->fd negative (allow for future module(s) which give fd away over unix domain socket) --- src/connections.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/connections.c b/src/connections.c index 5db36b74..898cd421 100644 --- a/src/connections.c +++ b/src/connections.c @@ -111,6 +111,8 @@ static int connection_del(server *srv, connection *con) { } static int connection_close(server *srv, connection *con) { + if (con->fd < 0) con->fd = -con->fd; + plugins_call_handle_connection_close(srv, con); fdevent_event_del(srv->ev, &(con->fde_ndx), con->fd); @@ -189,7 +191,7 @@ static void connection_handle_shutdown(server *srv, connection *con) { connection_reset(srv, con); /* close the connection */ - if ((0 == shutdown(con->fd, SHUT_WR))) { + if (con->fd >= 0 && 0 == shutdown(con->fd, SHUT_WR)) { con->close_timeout_ts = srv->cur_ts; connection_set_state(srv, con, CON_STATE_CLOSE); @@ -1366,7 +1368,7 @@ int connection_state_machine(server *srv, connection *con) { default: break; } - if (-1 != con->fd) { + if (con->fd >= 0) { const int events = fdevent_event_get_interest(srv->ev, con->fd); if (con->is_readable < 0) { con->is_readable = 0;