diff --git a/cmake/os.cmake b/cmake/os.cmake index 0ed554b9b1de1c57d94e442e5471f2cedfdcd481..cf6eac10d18e8d06d2050988706ab045febaa74a 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 fc8f00e0ef5e69e208467e3b373dc637094687ff..5cd9bfed334c0aa74ccb3c20e6418d243d2c2556 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;