Skip to content

Commit e541dfc

Browse files
Revert "Make poll() the default (yhirose#2065)"
This reverts commit 6e73a63.
1 parent b641cd9 commit e541dfc

File tree

6 files changed

+8
-57
lines changed

6 files changed

+8
-57
lines changed

.github/workflows/test.yaml

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,14 @@ jobs:
4343
(github.event_name == 'pull_request' &&
4444
github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) ||
4545
(github.event_name == 'workflow_dispatch' && github.event.inputs.test_linux == 'true')
46-
strategy:
47-
matrix:
48-
select_impl: ['select', 'poll']
4946
steps:
5047
- name: checkout
5148
uses: actions/checkout@v4
5249
- name: install libraries
5350
run: sudo apt-get update && sudo apt-get install -y libbrotli-dev libcurl4-openssl-dev
5451
- name: build and run tests
55-
env:
56-
SELECT_IMPL: ${{ matrix.select_impl }}
5752
run: cd test && make
5853
- name: run fuzz test target
59-
env:
60-
SELECT_IMPL: ${{ matrix.select_impl }}
6154
run: cd test && make fuzz_test
6255

6356
macos:
@@ -67,19 +60,12 @@ jobs:
6760
(github.event_name == 'pull_request' &&
6861
github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) ||
6962
(github.event_name == 'workflow_dispatch' && github.event.inputs.test_macos == 'true')
70-
strategy:
71-
matrix:
72-
select_impl: ['select', 'poll']
7363
steps:
7464
- name: checkout
7565
uses: actions/checkout@v4
7666
- name: build and run tests
77-
env:
78-
SELECT_IMPL: ${{ matrix.select_impl }}
7967
run: cd test && make
8068
- name: run fuzz test target
81-
env:
82-
SELECT_IMPL: ${{ matrix.select_impl }}
8369
run: cd test && make fuzz_test
8470

8571
windows:
@@ -89,9 +75,6 @@ jobs:
8975
(github.event_name == 'pull_request' &&
9076
github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) ||
9177
(github.event_name == 'workflow_dispatch' && github.event.inputs.test_windows == 'true')
92-
strategy:
93-
matrix:
94-
select_impl: ['select', 'poll']
9578
steps:
9679
- name: Prepare Git for Checkout on Windows
9780
run: |
@@ -113,33 +96,16 @@ jobs:
11396
choco install openssl
11497
11598
- name: Configure CMake with SSL
116-
run: >
117-
cmake -B build -S .
118-
-DCMAKE_BUILD_TYPE=Release
119-
-DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake
120-
-DHTTPLIB_TEST=ON
121-
-DHTTPLIB_REQUIRE_OPENSSL=ON
122-
-DHTTPLIB_REQUIRE_ZLIB=ON
123-
-DHTTPLIB_REQUIRE_BROTLI=ON
124-
-DHTTPLIB_USE_SELECT=${{ matrix.select_impl == 'select' && 'ON' || 'OFF' }}
99+
run: cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake -DHTTPLIB_TEST=ON -DHTTPLIB_REQUIRE_OPENSSL=ON -DHTTPLIB_REQUIRE_ZLIB=ON -DHTTPLIB_REQUIRE_BROTLI=ON
125100
- name: Build with with SSL
126-
run: cmake --build build --config Release -- /v:m /clp:ShowCommandLine /nologo
101+
run: cmake --build build --config Release
127102
- name: Run tests with SSL
128103
run: ctest --output-on-failure --test-dir build -C Release
129104

130105
- name: Configure CMake without SSL
131-
run: >
132-
cmake -B build-no-ssl -S .
133-
-DCMAKE_BUILD_TYPE=Release
134-
-DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake
135-
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
136-
-DHTTPLIB_TEST=ON
137-
-DHTTPLIB_REQUIRE_OPENSSL=OFF
138-
-DHTTPLIB_REQUIRE_ZLIB=ON
139-
-DHTTPLIB_REQUIRE_BROTLI=ON
140-
-DHTTPLIB_USE_SELECT=${{ matrix.select_impl == 'select' && 'ON' || 'OFF' }}
106+
run: cmake -B build-no-ssl -S . -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake -DHTTPLIB_TEST=ON -DHTTPLIB_REQUIRE_OPENSSL=OFF -DHTTPLIB_REQUIRE_ZLIB=ON -DHTTPLIB_REQUIRE_BROTLI=ON
141107
- name: Build without SSL
142-
run: cmake --build build-no-ssl --config Release -- /v:m /clp:ShowCommandLine /nologo
108+
run: cmake --build build-no-ssl --config Release
143109
- name: Run tests without SSL
144110
run: ctest --output-on-failure --test-dir build-no-ssl -C Release
145111
env:

CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
* HTTPLIB_REQUIRE_ZLIB (default off)
99
* HTTPLIB_REQUIRE_BROTLI (default off)
1010
* HTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN (default on)
11-
* HTTPLIB_USE_SELECT (default off) choose between select() and poll()
1211
* HTTPLIB_COMPILE (default off)
1312
* HTTPLIB_INSTALL (default on)
1413
* HTTPLIB_TEST (default off)
@@ -47,7 +46,6 @@
4746
* HTTPLIB_IS_USING_ZLIB - a bool for if ZLIB support is enabled.
4847
* HTTPLIB_IS_USING_BROTLI - a bool for if Brotli support is enabled.
4948
* HTTPLIB_IS_USING_CERTS_FROM_MACOSX_KEYCHAIN - a bool for if support of loading system certs from the Apple Keychain is enabled.
50-
* HTTPLIB_IS_USING_SELECT - a bool for if select() is used instead of poll().
5149
* HTTPLIB_IS_COMPILED - a bool for if the library is compiled, or otherwise header-only.
5250
* HTTPLIB_INCLUDE_DIR - the root path to httplib's header (e.g. /usr/include).
5351
* HTTPLIB_LIBRARY - the full path to the library if compiled (e.g. /usr/lib/libhttplib.so).
@@ -103,7 +101,6 @@ option(HTTPLIB_TEST "Enables testing and builds tests" OFF)
103101
option(HTTPLIB_REQUIRE_BROTLI "Requires Brotli to be found & linked, or fails build." OFF)
104102
option(HTTPLIB_USE_BROTLI_IF_AVAILABLE "Uses Brotli (if available) to enable Brotli decompression support." ON)
105103
option(HTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN "Enable feature to load system certs from the Apple Keychain." ON)
106-
option(HTTPLIB_USE_SELECT "Uses select() instead of poll()." OFF)
107104
# Defaults to static library
108105
option(BUILD_SHARED_LIBS "Build the library as a shared library instead of static. Has no effect if using header-only." OFF)
109106
if (BUILD_SHARED_LIBS AND WIN32 AND HTTPLIB_COMPILE)
@@ -115,7 +112,6 @@ endif()
115112
# Set some variables that are used in-tree and while building based on our options
116113
set(HTTPLIB_IS_COMPILED ${HTTPLIB_COMPILE})
117114
set(HTTPLIB_IS_USING_CERTS_FROM_MACOSX_KEYCHAIN ${HTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN})
118-
set(HTTPLIB_IS_USING_SELECT ${HTTPLIB_USE_SELECT})
119115

120116
# Threads needed for <thread> on some systems, and for <pthread.h> on Linux
121117
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
@@ -242,7 +238,6 @@ target_compile_definitions(${PROJECT_NAME} ${_INTERFACE_OR_PUBLIC}
242238
$<$<BOOL:${HTTPLIB_IS_USING_ZLIB}>:CPPHTTPLIB_ZLIB_SUPPORT>
243239
$<$<BOOL:${HTTPLIB_IS_USING_OPENSSL}>:CPPHTTPLIB_OPENSSL_SUPPORT>
244240
$<$<AND:$<PLATFORM_ID:Darwin>,$<BOOL:${HTTPLIB_IS_USING_OPENSSL}>,$<BOOL:${HTTPLIB_IS_USING_CERTS_FROM_MACOSX_KEYCHAIN}>>:CPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN>
245-
$<$<BOOL:${HTTPLIB_IS_USING_SELECT}>:CPPHTTPLIB_USE_SELECT>
246241
)
247242

248243
# CMake configuration files installation directory

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM yhirose4dockerhub/ubuntu-builder AS builder
22
WORKDIR /build
33
COPY httplib.h .
44
COPY docker/main.cc .
5-
RUN g++ -std=c++23 -static -o server -O2 -I. main.cc && strip server
5+
RUN g++ -std=c++23 -static -o server -O2 -I. -DCPPHTTPLIB_USE_POLL main.cc && strip server
66

77
FROM scratch
88
COPY --from=builder /build/server /server

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -872,10 +872,10 @@ res->body; // Compressed data
872872

873873
```
874874

875-
Use `select()` instead of `poll()`
876-
----------------------------------
875+
Use `poll` instead of `select`
876+
------------------------------
877877

878-
cpp-httplib defaults to the widely supported `poll()` system call. If your OS lacks support for `poll()`, define `CPPHTTPLIB_USE_SELECT` to use `select()` instead.
878+
`select` system call is used as default since it's more widely supported. If you want to let cpp-httplib use `poll` instead, you can do so with `CPPHTTPLIB_USE_POLL`.
879879

880880
Unix Domain Socket Support
881881
--------------------------

httplib.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,6 @@
145145
#define CPPHTTPLIB_LISTEN_BACKLOG 5
146146
#endif
147147

148-
#if !defined(CPPHTTPLIB_USE_POLL) && !defined(CPPHTTPLIB_USE_SELECT)
149-
#define CPPHTTPLIB_USE_POLL
150-
#elif defined(CPPHTTPLIB_USE_POLL) && defined(CPPHTTPLIB_USE_SELECT)
151-
#error "CPPHTTPLIB_USE_POLL and CPPHTTPLIB_USE_SELECT are mutually exclusive"
152-
#endif
153-
154148
/*
155149
* Headers
156150
*/

test/Makefile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
CXX = clang++
22
CXXFLAGS = -g -std=c++11 -I. -Wall -Wextra -Wtype-limits -Wconversion -Wshadow # -fno-exceptions -DCPPHTTPLIB_NO_EXCEPTIONS -fsanitize=address
33

4-
ifeq ($(SELECT_IMPL),select)
5-
CXXFLAGS += -DCPPHTTPLIB_USE_SELECT
6-
endif
7-
84
PREFIX ?= $(shell brew --prefix)
95

106
OPENSSL_DIR = $(PREFIX)/opt/openssl@3

0 commit comments

Comments
 (0)