Unverified Commit 5de6a762 authored by Alberto Miranda's avatar Alberto Miranda ♨️
Browse files

USE_BITSET_FOR_INTERNAL_FDS is now the default

parent 9ab384e8
Loading
Loading
Loading
Loading
+7 −18
Original line number Diff line number Diff line
@@ -122,9 +122,6 @@ set(MAX_INTERNAL_FDS 256 CACHE STRING "Number of file descriptors reserved for i
add_definitions(-DMAX_INTERNAL_FDS=${MAX_INTERNAL_FDS})
message(STATUS "File descriptors reserved for internal use: ${MAX_INTERNAL_FDS}")

option(USE_BITSET_FOR_INTERNAL_FDS "Use std::bitset to track internal fds" ON)
if(USE_BITSET_FOR_INTERNAL_FDS)
    add_definitions(-DUSE_BITSET_FOR_INTERNAL_FDS)
execute_process(COMMAND getconf OPEN_MAX
                OUTPUT_VARIABLE GETCONF_MAX_FDS
                OUTPUT_STRIP_TRAILING_WHITESPACE
@@ -133,14 +130,6 @@ if(USE_BITSET_FOR_INTERNAL_FDS)
    set(GETCONF_MAX_FDS=512)
endif()
add_definitions(-DMAX_OPEN_FDS=${GETCONF_MAX_FDS})
endif()

message(STATUS "Use std::bitset for internal fd tracking: ${USE_BITSET_FOR_INTERNAL_FDS}")

if(USE_BITSET_FOR_INTERNAL_FDS)
    message(STATUS "Max open files: ${GETCONF_MAX_FDS}")
endif()


option(ENABLE_LOGGING "Disable all logging messages" ON)
if(NOT ENABLE_LOGGING)
+0 −7
Original line number Diff line number Diff line
@@ -21,9 +21,7 @@
#include <vector>
#include <string>

#ifdef USE_BITSET_FOR_INTERNAL_FDS
#include <bitset>
#endif // USE_BITSET_FOR_INTERNAL_FDS

/* Forward declarations */
class OpenFileMap;
@@ -77,13 +75,8 @@ class PreloadContext {

    bool interception_enabled_;

#ifdef USE_BITSET_FOR_INTERNAL_FDS
    std::bitset<MAX_INTERNAL_FDS> internal_fds_;
    mutable std::mutex internal_fds_mutex_;
#else
    std::set<int> internal_fds_;
#endif // USE_BITSET_FOR_INTERNAL_FDS


    public:
    static PreloadContext* getInstance() {
+0 −3
Original line number Diff line number Diff line
@@ -33,10 +33,7 @@ PreloadContext::PreloadContext():
    ofm_(std::make_shared<OpenFileMap>()),
    fs_conf_(std::make_shared<FsConfig>()) {

#ifdef USE_BITSET_FOR_INTERNAL_FDS
    internal_fds_.set();
#endif // USE_BITSET_FOR_INTERNAL_FDS
    
}

void