Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unblock the accept thread on shutdown
Merge #120 a=@moises-silva r=@frewsxcv ________________________________________________________________________ I'd like to find a better way, but, this works and is not completely awful, is it? :) If this is not acceptable I'd like to initiate a discussion on ideas on how to handle shutdown correctly. Currently if tiny-http is used in a loadable module (I am using it inside a project that can load/unload modules from an interactive command line a system administrator controls), when the server goes out of scope the socket lingers because the thread never terminates unless there's a new tcp connection received (accept is a blocking call). An alternative to this would be to put the socket in non-blocking mode and then somehow poll() or select() on it with a timeout to check every sec for the shutdown flag (close trigger bool). I may be wrong, but I don't see many downsides to this implementation. The Drop() call *could* hang for a bit on unusual situations like the server being inaccessible to itself (e.g 127 -> 127 firewall blocking or whatever), but the connection will timeout and move on. Most cases are better off with this as far as I can tell. Thoughts?
- Loading branch information