From: "Timur Safin" <tsafin@tarantool.org>
To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org,
Cyrill Gorcunov <gorcunov@tarantool.org>
Subject: [Tarantool-patches] [PATCH v1.2] evio: workaround for wsl1 so_linger assertion
Date: Thu, 19 Mar 2020 13:27:08 +0300 [thread overview]
Message-ID: <0f1501d5fdd8$f21e6860$d65b3920$@tarantool.org> (raw)
In-Reply-To: <bb3eef527b48bdd3aacddc27e0597ceedcb84987.1584371177.git.tsafin@tarantool.org>
SO_LINGER makes no much sense for unix-sockets, and Microsoft WSL
is returning EINVAL if setsockopts called for SO_LINGER over unix
sockets:
[004] 2020-03-11 18:42:29.592 [29182] main/102/app sio.c:169 !> SystemError setsockopt(SO_LINGER), called on fd 16, aka
[004] 2020-03-11 18:42:29.592 [29182] main/102/app F> can't initialize storage: setsockopt(SO_LINGER), called on fd 16,
[004] 2020-03-11 18:42:29.592 [29182] main/102/app F> can't initialize storage: setsockopt(SO_LINGER), called on fd 16,
And it's sort of correct here, but the problem is Linux is simply
silently ignoring it, which passes tests.
After much debates we decided to work-around this case via CMAKE
define.
NB! In a future (April/May 2020), when WSL2 with full Linux kernel
would be released we should disable this check.
Acked-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
This patch replaces prior one tsafin/gh-4659-wsl-no-linger-assert, and tsafin/wsl1-no-linger-assert
because original approach considered unsafe, and we rather want to workaround it via CMake instead.
Patch 1.2 - got rid of pure stylistic cmake changes.
Branch: https://github.com/tarantool/tarantool/tree/tsafin/wsl1-no-linger-assert-2
cmake/os.cmake | 9 +++++++++
src/lib/core/evio.c | 2 ++
2 files changed, 11 insertions(+)
diff --git a/cmake/os.cmake b/cmake/os.cmake
index 0ed554b9b..cf6eac10d 100644
--- a/cmake/os.cmake
+++ b/cmake/os.cmake
@@ -11,6 +11,15 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
# (see man page for feature_test_macros).
add_definitions("-D_FILE_OFFSET_BITS=64")
find_package_message(PLATFORM "Building for Linux" "${CMAKE_SYSTEM_NAME}")
+
+ # There are some subtle differences in Linux kernel calls
+ # implementation under WSL1 (which should go away with WSL2 kernel)
+ # so for a moment we introduce a way to distinguish Linux and
+ # Microsoft/WSL1
+ if (${CMAKE_SYSTEM} MATCHES "Linux-.*-Microsoft")
+ add_definitions("-DTARANTOOL_WSL1_WORKAROUND_ENABLED=1")
+ endif()
+
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD")
set(TARGET_OS_FREEBSD 1)
set(TARGET_OS_DEBIAN_FREEBSD 1)
diff --git a/src/lib/core/evio.c b/src/lib/core/evio.c
index 2152c15e6..e1eab44d1 100644
--- a/src/lib/core/evio.c
+++ b/src/lib/core/evio.c
@@ -140,6 +140,7 @@ evio_setsockopt_server(int fd, int family, int type)
&on, sizeof(on)))
return -1;
+#ifndef TARANTOOL_WSL1_WORKAROUND_ENABLED
/* Send all buffered messages on socket before take
* control out from close(2) or shutdown(2). */
struct linger linger = { 0, 0 };
@@ -147,6 +148,7 @@ evio_setsockopt_server(int fd, int family, int type)
if (sio_setsockopt(fd, SOL_SOCKET, SO_LINGER,
&linger, sizeof(linger)))
return -1;
+#endif
if (type == SOCK_STREAM && family != AF_UNIX &&
evio_setsockopt_keepalive(fd) != 0)
return -1;
--
2.20.1
next prev parent reply other threads:[~2020-03-19 10:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <bb3eef527b48bdd3aacddc27e0597ceedcb84987.1584371177.git.tsafin@tarantool.org>
2020-03-16 16:53 ` [Tarantool-patches] [PATCH v1.1] " Timur Safin
2020-03-16 22:35 ` Vladislav Shpilevoy
2020-03-17 14:40 ` Timur Safin
2020-03-17 21:27 ` Vladislav Shpilevoy
2020-03-18 7:12 ` Timur Safin
2020-03-19 10:27 ` Timur Safin [this message]
2020-03-19 10:52 ` [Tarantool-patches] [PATCH v1.2] " Cyrill Gorcunov
2020-03-19 11:07 ` Timur Safin
2020-03-22 19:21 ` Vladislav Shpilevoy
2020-03-23 23:12 ` Vladislav Shpilevoy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='0f1501d5fdd8$f21e6860$d65b3920$@tarantool.org' \
--to=tsafin@tarantool.org \
--cc=gorcunov@tarantool.org \
--cc=tarantool-patches@dev.tarantool.org \
--cc=v.shpilevoy@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH v1.2] evio: workaround for wsl1 so_linger assertion' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox