Skip to content
Snippets Groups Projects
Commit 734bcafc authored by Timur Safin's avatar Timur Safin Committed by Vladislav Shpilevoy
Browse files

evio: workaround for wsl1 so_linger assertion


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: default avatarCyrill Gorcunov <gorcunov@gmail.com>
parent 17f6af7d
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment