Mirror of the Rel4tion website/wiki source, view at <http://rel4tion.org>
Clone
HTTPS:
git clone https://vervis.peers.community/repos/yEzqv
SSH:
git clone USERNAME@vervis.peers.community:yEzqv
Branches
Tags
1.mdwn
[[!template id=ticket class=task assigned=fr33domlover]]
[[!meta title=“Timeouts”]]
Issue
When the server accepts a connection from a client, it’s just a regular TCP connection. Every time the servers waits for an HTTP request to process, there is a chance no such request will ever be sent. Either because it was an empty TCP connection, or because the client didn’t close the connection, or some other issue. Either way, these dangling connections should be closed.
Web servers generally close them after some time, e.g. 5 seconds. http-listen
should have a way to track and close inactive connections and the threads in which they run.
Plan
Suppose our timeout is T seconds. Then we can have a checker operation which runs once every T seconds, but only if there are actually open connections. As long as there is one at least, check every T seconds. Otherwise, go to sleep until woken up by a new open connection.
Every time the checker runs, it goes over the open connections. Each connection which has been inactive for T seconds or more, gets closed (and its thread closed too).
Now, how to connection threads report activity? Every time a thread is about to receiveHTTP
, it starts the timer. Right after that, when done getting the request, it stops the timer and applies the listener to the request. If it wants to wait for another request, it restarts the timer. And so on.
The package [[!hackage auto-update]] can help with that, once I figure out how to use it. But even without it, it looks like a task which can be done with standard concurrency tools.
Result
None yet.