[ https://issues.apache.org/jira/browse/THRIFT-2441?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14391544#comment-14391544 ]
James E. King, III commented on THRIFT-2441: -------------------------------------------- That seems reasonable, however the interrupt mechanism in TServerSocket does not know if it is being interrupted or being stopped. Per Randy's provided use case we need to maintain that functionality, so it would be necessary to add a stop() method that first sets a boolean stop flag, and then calls interrupt in much the same way. It would also be necessary to have the death_listener be a third socket pair that is independent of the interrupt socket pair, where the server socket owns the sending side and the server socket + client sockets communally own the receiving side of the death_listener, and the clients do not attempt to read off it to clear the condition when it is set. For that reason I would make the death_listener a shared pointer with a custom deletion method to allow the server socket to complete stop() and return to the TServer's stop, which will in turn exit the main serve() loop and cause the TThreadedServer to wait for the drain event it already has (all tasks, i.e. all clients, drained). As the last TSocket child of that particular TServerSocket is destroyed, that death_listener socket will destroy itself. This isolates the majority of the changes to TServerSocket and TSocket without needing to touch TServerTransport, TTransport, or TServer. Not certain how to translate this to Windows yet. It is a shame that the socket shutdown() call does not unblock a recv call. That would atomically set the socket to a state where recv cannot be called again, and break it out of the loop, and allow it to be closed safely. > Cannot shutdown TThreadedServer when clients are still connected > ---------------------------------------------------------------- > > Key: THRIFT-2441 > URL: https://issues.apache.org/jira/browse/THRIFT-2441 > Project: Thrift > Issue Type: Bug > Components: C++ - Library > Affects Versions: 0.9.1 > Reporter: Chris Stylianou > Assignee: Ben Craig > > When calling stop() on the TThreadedServer no interrupts are sent to the > client threads. This means the stop() call blocks on tasksMonitor.wait() > until all client naturally disconnect. > How can we tell the client thread connections to close/exit during the > TThreadedServer::stop() call? -- This message was sent by Atlassian JIRA (v6.3.4#6332)