Skip to content

Commit

Permalink
Support splice in http blind tunnel
Browse files Browse the repository at this point in the history
1. Add TS_USE_LINUX_SPLICE as a compilation option.
2. Make MIOBuffer and MIOBufferReader polymorphic classes making their member function virtual.
3. Create PipeIOBuffer and PipeIOBufferReader as derived classed, encapsulating Linux pipe.
4. Use dynamic_cast to enable logic switch in state machines and continuations.
  • Loading branch information
YIHONG-JIN committed Dec 20, 2024
1 parent b65a841 commit 5a1b3ee
Show file tree
Hide file tree
Showing 11 changed files with 898 additions and 63 deletions.
15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,21 @@ list(APPEND CMAKE_REQUIRED_LIBRARIES pthread)
check_symbol_exists(pthread_getname_np pthread.h HAVE_PTHREAD_GETNAME_NP)
check_symbol_exists(pthread_get_name_np pthread.h HAVE_PTHREAD_GET_NAME_NP)

option(USE_SPLICE "Enable the use of splice(2) for zero copy (default OFF) (linux only)" OFF)

# Check for the splice function
include(CheckFunctionExists)
check_function_exists(splice HAVE_SPLICE)

# Configure USE_SPLICE based on both availability and user option
if(HAVE_SPLICE AND USE_SPLICE)
message(STATUS "splice is available and enabled.")
set(TS_USE_LINUX_SPLICE 1) # Use ON for true
else()
message(STATUS "splice is either not available or disabled by the user.")
set(TS_USE_LINUX_SPLICE 0) # Use OFF for false
endif()

check_source_compiles(
C "#include <pthread.h>
void main() { pthread_setname_np(\"name\"); }" HAVE_PTHREAD_SETNAME_NP_1
Expand Down
13 changes: 13 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@
"CMAKE_COMPILE_WARNING_AS_ERROR": "ON"
}
},
{
"name": "default-splice",
"displayName": "Default build with splice",
"description": "Default build using Ninja generator with splice",
"inherits": ["default"],
"binaryDir": "${sourceDir}/build-${presetName}",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_COLOR_DIAGNOSTICS": "ON",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"USE_SPLICE": "ON"
}
},
{
"name": "layout-defaults",
"displayName": "Default install layout paths template",
Expand Down
Loading

0 comments on commit 5a1b3ee

Please sign in to comment.