Stream: git-wasmtime

Topic: wasmtime / PR #8738 Set `SO_REUSEADDR` again for `wasmtim...


view this post on Zulip Wasmtime GitHub notifications bot (Jun 03 2024 at 18:59):

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 with SO_REUSEPORT. Without SO_REUSEADDR it's possible to have this happen:

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. Setting SO_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:

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->

view this post on Zulip Wasmtime GitHub notifications bot (Jun 03 2024 at 18:59):

alexcrichton requested elliottt for a review on PR #8738.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 03 2024 at 18:59):

alexcrichton requested wasmtime-core-reviewers for a review on PR #8738.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 03 2024 at 19:05):

elliottt submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 03 2024 at 19:13):

alexcrichton updated PR #8738.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 03 2024 at 19:16):

alexcrichton updated PR #8738.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 03 2024 at 19:29):

alexcrichton edited PR #8738.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 03 2024 at 19:30):

alexcrichton edited PR #8738:

This effectively reverts #7863 which was a misunderstanding on my part about SO_REUSEADDR. I think I mixed it up with SO_REUSEPORT. Without SO_REUSEADDR it's possible to have this happen:

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. Setting SO_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 off SO_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:

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->

view this post on Zulip Wasmtime GitHub notifications bot (Jun 03 2024 at 19:32):

alexcrichton updated PR #8738.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 03 2024 at 19:35):

alexcrichton updated PR #8738.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 03 2024 at 19:35):

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.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 03 2024 at 19:35):

alexcrichton has enabled auto merge for PR #8738.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 03 2024 at 19:58):

alexcrichton merged PR #8738.


Last updated: Nov 22 2024 at 17:03 UTC