Waking up a blocked socket during shutdown
843790Dec 15 2006 — edited Dec 21 2006I have a server app that takes requests from client and uses Threads to handle connections. Socket timeout is used and I want to allow a long timeout to be configurable.
However, I want be able to wake up a socket that may be blocked on a read during shutdown of my server otherwise it's possible for an idle client connected to my server to prevent shutdown until the timeout.
I cannot make these thread daemon threads as they perform disk I/O and I do not want to introduce some chance of I/O corruption if the VM exits while a thread is writing some data.
One thing I have tried is to keep a Set of all open Sockets and the shutdown initiator does Socket.close() on all pending connections after the initial shutdown timeout. That works, but it's not the cleanest of solutions.
Does anyone have any suggestions on ways to achieve graceful shutdown?
Thanks
Antony
null