Skip to content

Commit 0f7fc70

Browse files
committed
Support splice in http blind tunnel
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.
1 parent b10652b commit 0f7fc70

15 files changed

+914
-63
lines changed

CMakeLists.txt

+15
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,21 @@ list(APPEND CMAKE_REQUIRED_LIBRARIES pthread)
429429
check_symbol_exists(pthread_getname_np pthread.h HAVE_PTHREAD_GETNAME_NP)
430430
check_symbol_exists(pthread_get_name_np pthread.h HAVE_PTHREAD_GET_NAME_NP)
431431

432+
option(USE_SPLICE "Enable the use of splice(2) for zero copy (default OFF) (linux only)" OFF)
433+
434+
# Check for the splice function
435+
include(CheckFunctionExists)
436+
check_function_exists(splice HAVE_SPLICE)
437+
438+
# Configure USE_SPLICE based on both availability and user option
439+
if(HAVE_SPLICE AND USE_SPLICE)
440+
message(STATUS "splice is available and enabled.")
441+
set(TS_USE_LINUX_SPLICE 1) # Use ON for true
442+
else()
443+
message(STATUS "splice is either not available or disabled by the user.")
444+
set(TS_USE_LINUX_SPLICE 0) # Use OFF for false
445+
endif()
446+
432447
check_source_compiles(
433448
C "#include <pthread.h>
434449
void main() { pthread_setname_np(\"name\"); }" HAVE_PTHREAD_SETNAME_NP_1

CMakePresets.json

+13
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@
1717
"CMAKE_COMPILE_WARNING_AS_ERROR": "ON"
1818
}
1919
},
20+
{
21+
"name": "default-splice",
22+
"displayName": "Default build with splice",
23+
"description": "Default build using Ninja generator with splice",
24+
"inherits": ["default"],
25+
"binaryDir": "${sourceDir}/build-${presetName}",
26+
"generator": "Ninja",
27+
"cacheVariables": {
28+
"CMAKE_COLOR_DIAGNOSTICS": "ON",
29+
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
30+
"USE_SPLICE": "ON"
31+
}
32+
},
2033
{
2134
"name": "layout-defaults",
2235
"displayName": "Default install layout paths template",

include/iocore/eventsystem/EventSystem.h

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "ts/apidefs.h"
3131

3232
#include "iocore/eventsystem/IOBuffer.h"
33+
#include "iocore/eventsystem/PipeIOBuffer.h"
3334
#include "iocore/eventsystem/Action.h"
3435
#include "iocore/eventsystem/Continuation.h"
3536
#include "iocore/eventsystem/EThread.h"

0 commit comments

Comments
 (0)