MXS-2122: Close listener socket on destruction
Even though directly closing the socket is not very neat in the architectural sense of things, it allows the best of both worlds: the socket is instantly closed and is open for reuse while the listener struct is still available as a reference. This change needs to be revised when the listeners are refactored into separate objects. Updated documentation to reflect the change in behavior.
This commit is contained in:
@ -1274,6 +1274,11 @@ void dcb_final_close(DCB* dcb)
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Only listeners are closed with a fd of -1
|
||||
mxb_assert(dcb->dcb_role == DCB_ROLE_SERVICE_LISTENER);
|
||||
}
|
||||
|
||||
dcb->state = DCB_STATE_DISCONNECTED;
|
||||
dcb_remove_from_list(dcb);
|
||||
|
||||
@ -751,6 +751,11 @@ bool service_remove_listener(Service* service, const char* target)
|
||||
{
|
||||
listener->listener->session->state = SESSION_STATE_LISTENER_STOPPED;
|
||||
rval = true;
|
||||
|
||||
// TODO: This is not pretty but it works, revise when listeners are refactored. This is
|
||||
// thread-safe as the listener is freed on the same thread that closes the socket.
|
||||
close(listener->listener->fd);
|
||||
listener->listener->fd = -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user