Do not set SO_REUSEADDR on Windows
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v6 Latest5 patches 2 repliesIn review
- v55 patches 7 repliesSuperseded
- v45 patches 3 repliesSuperseded
Earlier versions · 3
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v3 | 5 patches | 6 replies | Superseded | |
| v2 | 5 patches | 5 replies | Superseded | |
| v1 RFC | 4 patches | 0 replies | Superseded |
Changes in v6 from the cover letter
- dropped error output and the silent parameter in favor of an assertion
Patches in v6 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/5 | util: add socket_set_fast_reuse function which will replace setting SO_REUSEADDRinclude/ util/ util/ | +23 | 0 replies | |
| 2/5 | gdbstub: call socket_set_fast_reuse instead of setting SO_REUSEADDRgdbstub.c | +2 | 0 replies | |
| 3/5 | net: call socket_set_fast_reuse instead of setting SO_REUSEADDRnet/ | +10 | 0 replies | |
| 4/5 | slirp: call socket_set_fast_reuse instead of setting SO_REUSEADDRslirp/ slirp/ slirp/ +1 more | +6 | 0 replies | |
| 5/5 | util: call socket_set_fast_reuse instead of setting SO_REUSEADDRutil/ | +3 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v6 yet.
Cover letter [Qemu-devel] [PATCH v6 0/5] Do not set SO_REUSEADDR on Windows
This patchset disables most uses of SO_REUSEADDR on Windows and replaces it with calls to the new function socket_set_fast_reuse. On Windows systems the default behaviour is equivalent to SO_REUSEADDR on other operating systems. SO_REUSEADDR can still be set but results in undesired behaviour in most cases. It may even lead to situations were system behaviour is unspecified. More information on this can be found at:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms740621.aspx
I originally encountered this issue when accidentally launching two QEMU instances with identical GDB ports at the same time. In which case QEMU won't fail as one might expect.
Note that patch #4 fails checkpatch.pl. This is intentional (see v3 changes).
v6 Changes:
- dropped error output and the silent parameter in favor of an assertion
Actually I wanted to remove the return value from the function too, as the assertion pretty much states that the function will not fail and thus always return 0. However this would make the code a little ugly to prevent unused variable warnings if NDEBUG is set (see patch 1) and also would require some ugly changes to slirp/socket.c (see patch 4). Thus I decided to keep it.
- Rebased to current master (a684f3cf9b9b9c3cb82be87aafc463de8974610c)
v5 Changes:
- Fixed inverted silent flag on all call sites of socket_set_fast_reuse
v4 Changes:
- Added the silent flag to socket_set_fast_reuse controlling error reporting One location where SO_REUSEADDR was set would report errors if setting the option failed. Keeping the reporting code there would be somewhat unclean, so I moved it to socket_set_fast_reuse. A side effect of this was that the error reporting was added for all locations that now use socket_set_fast_reuse. Here a new flag is added to control error reporting, which means this patchset won't change QEMU behaviour (except for not setting SO_REUSEADDR on Windows).
- Fixed a commit message typo
- Rebased to current master (2d1fe1873a984d1c2c89ffa3d12949cafc718551).
v3 Changes:
- Fixed coding style issues.
According to checkpatch.pl patch #4 still introduces style errors as tabs are used instead of space for some indentation. I keept the tabs to stay consistent with the sourrounding code, as tabs seem to be used consitently in parts (all?) of the slirp code.
- Changed patch #3 to keep SO_REUSEADDR for multicast sockets on windows and added an explainatory comment.
- Rebased to current master (94c2b6aff43cdfcfdfb552773a6b6b973a72ef0b).
v2 Changes:
- Introduce a function with os specific implementation instead of using #ifdef I named it socket_set_fast_reuse instead of the suggested qemu_set_reuseaddr so the name better reflects what the function actually does.
gdbstub.c | 6 ++---- include/qemu/sockets.h | 1 + net/socket.c | 19 ++++++++++--------- slirp/misc.c | 3 +-- slirp/socket.c | 4 +--- slirp/tcp_subr.c | 6 ++---- slirp/udp.c | 4 ++-- util/oslib-posix.c | 12 ++++++++++++ util/oslib-win32.c | 10 ++++++++++ util/qemu-sockets.c | 6 +++--- 10 files changed, 44 insertions(+), 27 deletions(-)
util: add socket_set_fast_reuse function which will
gdbstub: call socket_set_fast_reuse instead of
net: call socket_set_fast_reuse instead of setting
slirp: call socket_set_fast_reuse instead of setting
util: call socket_set_fast_reuse instead of setting