Commit 456e52aa authored by David Auer's avatar David Auer
Browse files

Workaround for MAX_OPEN_FDS

parent 8487c78f
Loading
Loading
Loading
Loading
+19 −8
Original line number Diff line number Diff line
@@ -123,14 +123,25 @@ set(MAX_INTERNAL_FDS 256 CACHE STRING "Number of file descriptors reserved for i
add_definitions(-DMAX_INTERNAL_FDS=${MAX_INTERNAL_FDS})
message(STATUS "[gekkofs] File descriptors reserved for internal use: ${MAX_INTERNAL_FDS}")

execute_process(COMMAND getconf OPEN_MAX
    OUTPUT_VARIABLE GETCONF_MAX_FDS
    OUTPUT_STRIP_TRAILING_WHITESPACE
    ERROR_QUIET)
if (NOT GETCONF_MAX_FDS)
    set(GETCONF_MAX_FDS=512)
endif ()
add_definitions(-DMAX_OPEN_FDS=${GETCONF_MAX_FDS})
# Workaround for MAX_OPEN_FDS mismatch between buildtime and runtime:
# VS Code seems to increase the soft limit on file descriptors for itself and
# its child processes to 4*1024, this gets compiled into the binary and 
# causes the client library to fail when run from a terminal with a lower limit
# (default is 1024 on my machine). Error:
# gekkofs/src/client/preload_context.cpp: int gkfs::preload::PreloadContext
# ::register_internal_fd(int): Assertion `::syscall_error_code(ifd) == 0' failed.
# Aborted (core dumped)
add_definitions(-DMAX_OPEN_FDS=1024)

# This is how we previously got the current OPEN_MAX_FDS from the environment:
# execute_process(COMMAND getconf OPEN_MAX
#     OUTPUT_VARIABLE GETCONF_MAX_FDS
#     OUTPUT_STRIP_TRAILING_WHITESPACE
#     ERROR_QUIET)
# if (NOT GETCONF_MAX_FDS)
#     set(GETCONF_MAX_FDS=512)
# endif ()
# add_definitions(-DMAX_OPEN_FDS=${GETCONF_MAX_FDS})

option(ENABLE_CLIENT_LOG "Enable logging messages" ON)
if (ENABLE_CLIENT_LOG)