Added extra debug and moved setting client timeout to just before the… #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Suggested patch to Issue #4 Handling of queued clients and timeout.
The read timeout on the client event was originally set at the time of the event accepting the socket connection in on_accept(). The accept is non-blocking so gets executed as soon as an incoming TCP connection arrives. The job was then entered onto the work queue, but not serviced if there were already no free threads available. Result was that the timeout expired before the worker thread could execute a read event, leading to "tail drop" of all events in the queue.
The patch modifies the timeout to be set just before the event is dispatched from the work queue i.e. in server_job_function() when the job has been pulled from the queue and there is a thread available to actually service the job. This means the timer is individual and relative to when the worker thread starts work for this client. Clients may still time out (at their end) waiting for service, but this change avoids the server opening connections and then not providing any service before timing out for all waiting jobs in the work queue.