-
Notifications
You must be signed in to change notification settings - Fork 121
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 forwarding reusePort
; use asynctools instead of fork now that PR was merged
#278
Open
timotheecour
wants to merge
3
commits into
dom96:master
Choose a base branch
from
timotheecour:pr_jester_fwd_reusePort
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Argh, this is quite frustrating. For httpbeast
reusePort
should be set to true by default by Jester, but then this creates an inconsistency. I guess let's just makereusePort
true by default for everything (even asynchttpserver):jester/jester.nim
Line 417 in 1809237
Optional
here).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the default in
std/newAsyncHttpServer
isreusePort = false
; false is the correct default to avoid connections being silently forwarded to the wrong server; this has always been the case since the flag was introduced in nim in 2015; the default should remainfalse
, like we discussed yesterday.Then everything is consistent betweem
std/newAsyncHttpServer
, jester, and httpbeast.For multithread, we can handle this in a second phase to also be consistent there, as dicussed yesterday.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
httpbeast needs to have this enabled by default and hence Jester does too. I don't know what you're suggesting, but if it's to just ignore the
false
value in httpbeast then I don't think that's right. If someone asks for no reusePort we should give it to them.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we discussed this yesterday:
https://discord.com/channels/371759389889003530/768367394547957761/860630931117965313
std/newAsyncHttpServer
--threads:on|off
which user could set for unrelated reasons even if using jester with numThreads = 1)reusePort = false
with numThreads > 1, and we can for now ignorereusePort = false
in this case (noting it in docs, as i had done in my httpbeast PR), and in followup work (which I can volunteer to do) honor it as discussed yesterday, by first binding to that port (which would fail if in use) and then running jester threads withresusePort = false
.to which you seemed to have agreed yesterday:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I know we discussed it yesterday. But I only now realised that this means we are going to ignore
reusePort
being set tofalse
.I would prefer to have
reusePort
set to true in Jester and same for httpbeast by default. Any reason not do this?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that was already the case before this PR, except it was worse because it was ignored for httpbeast but not for
useHttpBeast = false
; at least with this PR it's honored regardless of useHttpBeast:on|off, so longnumThreads = 1
and in the suggested future work, it'll be honored in all cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason is
reusePort = false
is the saner default, and is also consistent with the setting instd/newAsyncHttpServer
, so that when you start a server on an already bound port, you fail fast instead of succeeding and wondering why requests you send to it are not being processed by the server you just launched (or worse, if such requests are sensitive and should only talk to the server you launched).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you'll already fail fast though via the bind trick though. This might not be the case for asynchttpserver for now (although we can add the same mechanism there as in httpbeast to make it so). I prefer speed by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't be subject to TOCTOU if numThreads = 1 (regardless of --threads:on|off), and users shouldn't have to opt-in to get the sane default.
I don't see why it would impact speed in any way.
Here, I've finally implemented honoring reusePort=false for multithreads, see dom96/httpbeast#50. This should remove any remaining concerns.