diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0fb30cc6..a0f66c76 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -242,13 +242,13 @@ jobs: timeout-minutes: 120 steps: - - name: Clone Boost.Corosio + - name: Clone Boost.Http uses: actions/checkout@v4 with: path: http-root - name: Setup C++ - uses: alandefreitas/cpp-actions/setup-cpp@v1.9.0 + uses: alandefreitas/cpp-actions/setup-cpp@v1.9.3 id: setup-cpp with: compiler: ${{ matrix.compiler }} @@ -257,7 +257,7 @@ jobs: trace-commands: true - name: Install packages - uses: alandefreitas/cpp-actions/package-install@v1.9.0 + uses: alandefreitas/cpp-actions/package-install@v1.9.3 id: package-install with: apt-get-add-architecture: ${{ matrix.x86 && 'i386' || '' }} @@ -267,22 +267,16 @@ jobs: zlib1g-dev libbrotli-dev ${{ matrix.x86 && 'zlib1g-dev:i386 libbrotli-dev:i386' || '' }} - - name: Clone Capy - uses: actions/checkout@v4 - with: - repository: cppalliance/capy - ref: ${{ (github.ref_name == 'master' && github.ref_name) || 'develop' }} - path: capy-root - - name: Clone Boost - uses: alandefreitas/cpp-actions/boost-clone@v1.9.0 + uses: alandefreitas/cpp-actions/boost-clone@v1.9.3 id: boost-clone with: branch: ${{ (github.ref_name == 'master' && github.ref_name) || 'develop' }} boost-dir: boost-source - modules-exclude-paths: '' + modules-exclude-paths: '-' scan-modules-dir: http-root - scan-modules-ignore: http,capy + patches: > + https://github.com/cppalliance/capy - name: ASLR Fix if: ${{ startsWith(matrix.runs-on, 'ubuntu' )}} @@ -308,7 +302,6 @@ jobs: # Remove module from boost-source rm -r "boost-source/libs/$module" || true - rm -r "boost-source/libs/capy" || true # Copy cached boost-source to an isolated boost-root cp -r boost-source boost-root @@ -322,11 +315,8 @@ jobs: # Patch boost-root with workspace module cp -r "$workspace_root"/http-root "libs/$module" - # Patch boost-root with capy dependency - cp -r "$workspace_root"/capy-root "libs/capy" - - name: Boost B2 Workflow - uses: alandefreitas/cpp-actions/b2-workflow@v1.9.0 + uses: alandefreitas/cpp-actions/b2-workflow@v1.9.3 if: ${{ !matrix.coverage }} env: ASAN_OPTIONS: ${{ ((matrix.compiler == 'apple-clang' || matrix.compiler == 'clang') && 'detect_invalid_pointer_pairs=0:strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1') || 'detect_invalid_pointer_pairs=2:strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1' }} @@ -346,7 +336,7 @@ jobs: stop-on-error: true - name: Boost CMake Workflow - uses: alandefreitas/cpp-actions/cmake-workflow@v1.9.0 + uses: alandefreitas/cpp-actions/cmake-workflow@v1.9.3 if: ${{ matrix.coverage || matrix.build-cmake || matrix.is-earliest }} with: source-dir: boost-root @@ -386,7 +376,7 @@ jobs: # This causes find_package(Boost COMPONENTS http) to fail because # boost_httpConfig.cmake is never installed. - name: Find Package Integration Workflow - uses: alandefreitas/cpp-actions/cmake-workflow@v1.9.0 + uses: alandefreitas/cpp-actions/cmake-workflow@v1.9.3 if: false # ${{ matrix.build-cmake || matrix.is-earliest }} with: source-dir: boost-root/libs/${{ steps.patch.outputs.module }}/test/cmake_test @@ -409,7 +399,7 @@ jobs: trace-commands: true - name: Subdirectory Integration Workflow - uses: alandefreitas/cpp-actions/cmake-workflow@v1.9.0 + uses: alandefreitas/cpp-actions/cmake-workflow@v1.9.3 if: ${{ matrix.build-cmake || matrix.is-earliest }} with: source-dir: boost-root/libs/${{ steps.patch.outputs.module }}/test/cmake_test @@ -429,7 +419,7 @@ jobs: ref-source-dir: boost-root/libs/http/test/cmake_test - name: Root Project CMake Workflow - uses: alandefreitas/cpp-actions/cmake-workflow@v1.9.0 + uses: alandefreitas/cpp-actions/cmake-workflow@v1.9.3 if: ${{ matrix.build-cmake || matrix.is-earliest }} with: source-dir: boost-root/libs/${{ steps.patch.outputs.module }} @@ -492,14 +482,14 @@ jobs: timeout-minutes: 120 steps: - - name: Clone Boost.Corosio + - name: Clone Boost.Http uses: actions/checkout@v4 with: # Avoid the common API rate limit exceeded error in boostorg by including 100 latest commits in any case fetch-depth: 100 - name: Changelog - uses: alandefreitas/cpp-actions/create-changelog@v1.9.0 + uses: alandefreitas/cpp-actions/create-changelog@v1.9.3 with: thank-non-regular: ${{ startsWith(github.ref, 'refs/tags/') }} github-token: ${{ secrets.GITHUB_TOKEN }} @@ -517,7 +507,7 @@ jobs: shell: bash steps: - name: Install packages - uses: alandefreitas/cpp-actions/package-install@v1.9.0 + uses: alandefreitas/cpp-actions/package-install@v1.9.3 with: apt-get: git cmake @@ -526,22 +516,16 @@ jobs: with: path: http-root - - name: Clone Capy - uses: actions/checkout@v4 - with: - repository: cppalliance/capy - ref: ${{ (github.ref_name == 'master' && github.ref_name) || 'develop' }} - path: capy-root - - name: Clone Boost - uses: alandefreitas/cpp-actions/boost-clone@v1.9.0 + uses: alandefreitas/cpp-actions/boost-clone@v1.9.3 id: boost-clone with: branch: ${{ (github.ref_name == 'master' && github.ref_name) || 'develop' }} boost-dir: boost-source - modules-exclude-paths: '' + modules-exclude-paths: '-' scan-modules-dir: http-root - scan-modules-ignore: http,capy + patches: > + https://github.com/cppalliance/capy - name: Patch Boost id: patch @@ -562,7 +546,6 @@ jobs: # Remove module from boost-source rm -r "boost-source/libs/$module" || true - rm -r "boost-source/libs/capy" || true # Copy cached boost-source to an isolated boost-root cp -r boost-source boost-root @@ -576,9 +559,6 @@ jobs: # Patch boost-root with workspace module cp -r "$workspace_root"/http-root "libs/$module" - # Patch boost-root with capy dependency - cp -r "$workspace_root"/capy-root "libs/capy" - - uses: actions/setup-node@v4 with: node-version: 18 diff --git a/include/boost/http/bcrypt.hpp b/include/boost/http/bcrypt.hpp index f6081665..78fc67bd 100644 --- a/include/boost/http/bcrypt.hpp +++ b/include/boost/http/bcrypt.hpp @@ -41,16 +41,15 @@ #include #include -#include #include #include +#include #include #include #include #include #include -#include #include #include @@ -532,10 +531,10 @@ struct hash_async_op } void await_suspend( - capy::coro cont, - capy::executor_ref caller_ex, - std::stop_token) + std::coroutine_handle cont, + capy::io_env const* env) { + auto caller_ex = env->executor; auto& pool = capy::get_system_context(); auto sys_ex = pool.get_executor(); capy::run_async(sys_ex, @@ -543,13 +542,13 @@ struct hash_async_op (result r) mutable { result_ = r; - caller_ex.dispatch(cont); + caller_ex.dispatch(cont).resume(); }, [this, cont, caller_ex] (std::exception_ptr ep) mutable { ep_ = ep; - caller_ex.dispatch(cont); + caller_ex.dispatch(cont).resume(); } )(hash_task(password_, rounds_, ver_)); } @@ -575,10 +574,10 @@ struct compare_async_op } void await_suspend( - capy::coro cont, - capy::executor_ref caller_ex, - std::stop_token) + std::coroutine_handle cont, + capy::io_env const* env) { + auto caller_ex = env->executor; auto& pool = capy::get_system_context(); auto sys_ex = pool.get_executor(); capy::run_async(sys_ex, @@ -586,13 +585,13 @@ struct compare_async_op (bool ok) mutable { result_ = ok; - caller_ex.dispatch(cont); + caller_ex.dispatch(cont).resume(); }, [this, cont, caller_ex] (std::exception_ptr ep) mutable { ep_ = ep; - caller_ex.dispatch(cont); + caller_ex.dispatch(cont).resume(); } )(compare_task(password_, hash_str_)); } diff --git a/src/server/serve_static.cpp b/src/server/serve_static.cpp index 92538cb3..d9e81397 100644 --- a/src/server/serve_static.cpp +++ b/src/server/serve_static.cpp @@ -297,28 +297,36 @@ operator()(route_params& rp) const // Calculate how much to send std::int64_t remaining = info.range_end - info.range_start + 1; - // Stream file content - constexpr std::size_t buf_size = 16384; - char buffer[buf_size]; - + // Stream file content using serializer's internal buffer while(remaining > 0) { + capy::mutable_buffer arr[1]; + auto bufs = rp.res_body.prepare(arr); + if(bufs.empty()) + { + auto [ec2] = co_await rp.res_body.commit(0); + if(ec2) + co_return route_error(ec2); + continue; + } + auto const to_read = static_cast( - (std::min)(remaining, static_cast(buf_size))); + (std::min)(remaining, + static_cast(bufs[0].size()))); - auto const n1 = f.read(buffer, to_read, ec); - if(ec.failed() || n1 == 0) + auto const n1 = f.read(bufs[0].data(), to_read, ec); + if(ec.failed()) + co_return route_error(ec); + if(n1 == 0) break; - auto [ec2, n2] = co_await rp.res_body.write( - capy::const_buffer(buffer, n1)); - (void)n2; + auto [ec2] = co_await rp.res_body.commit(n1); if(ec2) co_return route_error(ec2); remaining -= static_cast(n1); } - auto [ec3] = co_await rp.res_body.write_eof(); + auto [ec3] = co_await rp.res_body.commit_eof(0); if(ec3) co_return route_error(ec3); co_return route_done; diff --git a/test/unit/Jamfile b/test/unit/Jamfile index b34e68c0..abeba948 100644 --- a/test/unit/Jamfile +++ b/test/unit/Jamfile @@ -42,6 +42,7 @@ project ../../../url/extra/test_suite extra on + gcc:"-Wno-maybe-uninitialized" # https://github.com/boostorg/url/issues/979 static ; diff --git a/test/unit/bcrypt.cpp b/test/unit/bcrypt.cpp index 31d47398..058c580a 100644 --- a/test/unit/bcrypt.cpp +++ b/test/unit/bcrypt.cpp @@ -9,7 +9,6 @@ #include -#include #include #include #include @@ -51,12 +50,12 @@ struct test_executor void on_work_started() const noexcept {} void on_work_finished() const noexcept {} - void dispatch(capy::coro h) const + std::coroutine_handle<> dispatch(std::coroutine_handle h) const { - h.resume(); + return h; } - void post(capy::coro h) const + void post(std::coroutine_handle h) const { h.resume(); } diff --git a/test/unit/json/json_sink.cpp b/test/unit/json/json_sink.cpp index 13d9a585..1f0003c3 100644 --- a/test/unit/json/json_sink.cpp +++ b/test/unit/json/json_sink.cpp @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -68,14 +67,14 @@ struct test_executor void on_work_started() const noexcept {} void on_work_finished() const noexcept {} - void dispatch(capy::coro h) const + std::coroutine_handle<> dispatch(std::coroutine_handle h) const { if(dispatch_count_) ++(*dispatch_count_); - h.resume(); + return h; } - void post(capy::coro h) const + void post(std::coroutine_handle h) const { h.resume(); }