fix(TCPServer): continues to accept connections after stop() #4892#4896
fix(TCPServer): continues to accept connections after stop() #4892#4896
Conversation
|
looks like the only way to do this is to have a thread-safe sockfd wrapper, or take the other route and allow nullptr return from connection factory |
|
In |
|
Also, first calling |
That can be internalized - tell factory to stop creating new connections before the existing ones are terminated. We just have to allow factory to return null to the dispatcher. That way, all a user has to do is respect the factory status and return null when stopped. |
|
If you handle this in the factory, by the time the factory returns null the connection has already been accepted and put in the dispatcher queue. Not calling accept() in the first place is preferable. |
I am not opposed to doing that. But doing it on accept is still not 100% bulletproof. If factory returns null, the accepted socket will die with the notification. Additionally, it gives more control to the factory, eg. it can limit the number of connections it is willing to create or refuse connections from certain clients etc. |
|
I'm ok with allowing the |
…::stop() and allow factory to return nullptr on connection creation request #4892
|
@obiltschnig do you want me to leave the sockfd atomic? there may be some benefit from it, but it is not nearly a proper solution for socket thread safety |
…4896) * fix(TCPServer): continues to accept connections after stop() #4892 * fix(TCPServer): first attempt to silence TSAN #4892 * fix(TCPServer): check stopped status after poll; add TCPServerFactory::stop() and allow factory to return nullptr on connection creation request #4892 * fix(TCPServer): initialize factory stopped flag #4892 * revert(SocketImpl): atomic sock fd
No description provided.