-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow processing connection requests in parallel #62
Conversation
…t() and connRequest.Reject()
@aler9 Thanks a lot for this patch. I merged the PR. There's still something to look into. Now it is possible to accept/reject a connection several times with |
@ioppermann thanks for the feedback and for maintaining the library. The question about calling struct connRequest {
// existing fields
once sync.Once
}
func (req *connRequest) Reject(reason RejectionReason) {
req.once.Do(func() {
// existing method
})
} |
Both functions will send some data on the wire that already has been sent. I prefer to prevent this if it can be done with little effort and it is nicer for the user of the library. Otherwise it must be clearly documented, that it should never be called more than once. I solved it such that first |
Fixes #59
Fixes bluenviron/mediamtx#3382
Currently, connection requests are processed in series, in the same loop, through a callback that is passed as argument to
Accept()
:When the connection request is subjected to lengthy checks, the next request cannot be processed until the first one is done. This causes QoS issues on client-side (i.e. clients cannot connect) and a waste of resources on server-side (since computational power cannot be fully used).
This patch provides 3 additional methods called
Listener.Accept2()
,ConnRequest.Accept()
andConnRequest.Reject()
that allow to solve the issue, in a way that is as similar as possible to the one of standard libraries:This patch is fully backward compatible with the existing
Accept()
method and logic.