alexcrichton opened PR #8738 from alexcrichton:serve-port-options
to bytecodealliance:main
:
This effectively reverts #7863 which was a misunderstanding on my part about
SO_REUSEADDR
. I think I mixed it up withSO_REUSEPORT
. WithoutSO_REUSEADDR
it's possible to have this happen:
- Start a
wasmtime serve
session- Connect to the session with
nc
- Kill the server
- Restarting the server no longer works
Due to the active TCP connection at the time the server was killed the socket/address is in the
TIME_WAIT
state which apparently prevents rebinding the port until the OS has a chance to clean up everything. SettingSO_REUSEADDR
enables rebinding the address quickly.Now in #7863 that was trying to fix #7852 which said that it was possible to have multiple
wasmtime serve
instances binding the same port. That can lead to confusion and is generally something we don't want. That being said #7863 didn't actually change anything on either macOS or Unix, so the issue may not be fixed.This PR additionally adds two new tests, both for rebinding an in-use port quickly and additionally ensuring the same port can't be listened to twice.
<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
alexcrichton requested elliottt for a review on PR #8738.
alexcrichton requested wasmtime-core-reviewers for a review on PR #8738.
elliottt submitted PR review.
alexcrichton updated PR #8738.
alexcrichton updated PR #8738.
alexcrichton edited PR #8738.
alexcrichton edited PR #8738:
This effectively reverts #7863 which was a misunderstanding on my part about
SO_REUSEADDR
. I think I mixed it up withSO_REUSEPORT
. WithoutSO_REUSEADDR
it's possible to have this happen:
- Start a
wasmtime serve
session- Connect to the session with
nc
- Kill the server
- Restarting the server no longer works
Due to the active TCP connection at the time the server was killed the socket/address is in the
TIME_WAIT
state which apparently prevents rebinding the port until the OS has a chance to clean up everything. SettingSO_REUSEADDR
enables rebinding the address quickly.Now in #7863 that was trying to fix #7852 which said that it was possible to have multiple
wasmtime serve
instances binding the same port. That can lead to confusion and is generally something we don't want. That being said #7863 didn't actually change anything on either macOS or Unix, although it did fix the issue on Windows. Turns out the fix for both these issues was to only turn offSO_REUSEADDR
on Windows, but leave it on for Unix.This PR additionally adds two new tests, both for rebinding an in-use port quickly and additionally ensuring the same port can't be listened to twice.
<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
alexcrichton updated PR #8738.
alexcrichton updated PR #8738.
alexcrichton commented on PR #8738:
Ok turns out the issue was that we want
SO_REUSEADDR
on Unix, but not Windows. The option means different things on different platforms. The two new tests assert we have the desired behavior on all platforms now, though.
alexcrichton has enabled auto merge for PR #8738.
alexcrichton merged PR #8738.
Last updated: Nov 22 2024 at 17:03 UTC