Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

serializer allows partial buffer consumption #117

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 38 additions & 32 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,52 +169,54 @@ jobs:
version: "*"
cxx: "clang++"
cc: "clang"
runs-on: "macos-14"
runs-on: "macos-15"
b2-toolset: "clang"
is-latest: true
name: "Apple-Clang (macOS 14)"
name: "Apple-Clang (macOS 15)"
build-type: "Release"
build-cmake: true

- compiler: "apple-clang"
version: "*"
cxx: "clang++"
cc: "clang"
runs-on: "macos-14"
runs-on: "macos-15"
b2-toolset: "clang"
is-latest: true
name: "Apple-Clang (macOS 14, ubsan)"
name: "Apple-Clang (macOS 15, ubsan)"
build-type: "RelWithDebInfo"
ubsan: true

- compiler: "apple-clang"
version: "*"
cxx: "clang++"
cc: "clang"
runs-on: "macos-14"
runs-on: "macos-15"
b2-toolset: "clang"
is-latest: true
name: "Apple-Clang (macOS 14, asan)"
name: "Apple-Clang (macOS 15, asan)"
build-type: "RelWithDebInfo"
asan: true

- compiler: "apple-clang"
version: "*"
cxx: "clang++"
cc: "clang"
runs-on: "macos-13"
runs-on: "macos-14"
b2-toolset: "clang"
name: "Apple-Clang (macOS 13)"
name: "Apple-Clang (macOS 14)"
build-type: "Release"
build-cmake: true

- compiler: "apple-clang"
version: "*"
cxx: "clang++"
cc: "clang"
runs-on: "macos-12"
runs-on: "macos-13"
b2-toolset: "clang"
name: "Apple-Clang (macOS 12)"
name: "Apple-Clang (macOS 13)"
build-type: "Release"
build-cmake: true

# Linux compilers
#
Expand Down Expand Up @@ -364,8 +366,7 @@ jobs:
latest-cxxstd: "20"
cxx: "g++-13"
cc: "gcc-13"
runs-on: "ubuntu-latest"
container: "ubuntu:23.04"
runs-on: "ubuntu-24.04"
b2-toolset: "gcc"
name: "GCC 13: C++17-20"
build-type: "Release"
Expand All @@ -377,8 +378,7 @@ jobs:
latest-cxxstd: "20"
cxx: "g++-13"
cc: "gcc-13"
runs-on: "ubuntu-latest"
container: "ubuntu:23.04"
runs-on: "ubuntu-24.04"
b2-toolset: "gcc"
is-latest: true
name: "GCC 13: C++17-20 (coverage)"
Expand Down Expand Up @@ -608,8 +608,7 @@ jobs:
latest-cxxstd: "20"
cxx: "clang++-17"
cc: "clang-17"
runs-on: "ubuntu-latest"
container: "ubuntu:23.10"
runs-on: "ubuntu-24.04"
b2-toolset: "clang"
name: "Clang 17: C++17-20"
build-type: "Release"
Expand All @@ -621,8 +620,7 @@ jobs:
latest-cxxstd: "20"
cxx: "clang++-16"
cc: "clang-16"
runs-on: "ubuntu-latest"
container: "ubuntu:23.04"
runs-on: "ubuntu-24.04"
b2-toolset: "clang"
name: "Clang 16: C++17-20"
build-type: "Release"
Expand Down Expand Up @@ -803,12 +801,20 @@ jobs:
container:
image: ${{ matrix.container }}
options: --privileged
volumes:
- /node20217:/node20217:rw,rshared
- ${{ startsWith(matrix.container, 'ubuntu:1') && '/node20217:/__e/node20:ro,rshared' || ' ' }}
timeout-minutes: 120

steps:
- name: Enable Node 16
- name: install nodejs20glibc2.17
if: ${{ startsWith( matrix.container, 'ubuntu:1' ) }}
run: |
echo "ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION=true" >> $GITHUB_ENV
apt-get update
apt-get -yqq install xz-utils curl
curl -LO https://archives.boost.io/misc/node/node-v20.9.0-linux-x64-glibc-217.tar.xz
tar -xf node-v20.9.0-linux-x64-glibc-217.tar.xz --strip-components 1 -C /node20217
ldd /__e/node20/bin/node

- name: Clone Boost.HTTP.Proto
uses: actions/checkout@v3
Expand All @@ -823,7 +829,7 @@ jobs:
ref: develop

- name: Setup C++
uses: alandefreitas/cpp-actions/[email protected].2
uses: alandefreitas/cpp-actions/[email protected].7
id: setup-cpp
with:
compiler: ${{ matrix.compiler }}
Expand All @@ -832,7 +838,7 @@ jobs:
trace-commands: true

- name: Install packages
uses: alandefreitas/cpp-actions/[email protected].2
uses: alandefreitas/cpp-actions/[email protected].7
id: package-install
with:
apt-get-add-architecture: 'i386'
Expand All @@ -841,7 +847,7 @@ jobs:
build-essential

- name: Clone Boost
uses: alandefreitas/cpp-actions/[email protected].2
uses: alandefreitas/cpp-actions/[email protected].7
id: boost-clone
with:
branch: ${{ (github.ref_name == 'master' && github.ref_name) || 'develop' }}
Expand All @@ -850,7 +856,7 @@ jobs:
scan-modules-ignore: http_proto

- name: Install zlib (Windows)
uses: alandefreitas/cpp-actions/[email protected].2
uses: alandefreitas/cpp-actions/[email protected].7
if: ${{ startsWith(matrix.runs-on, 'windows') && !matrix.skip-zlib }}
id: zlib-install
with:
Expand Down Expand Up @@ -918,7 +924,7 @@ jobs:
python3 tools/boostdep/depinst/depinst.py $module

- name: Boost B2 Workflow
uses: alandefreitas/cpp-actions/[email protected].2
uses: alandefreitas/cpp-actions/[email protected].7
if: ${{ !matrix.coverage && !matrix.time-trace }}
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' }}
Expand All @@ -940,7 +946,7 @@ jobs:
extra-args: ${{ (matrix.valgrind && 'testing.launcher=valgrind' || '' )}}

- name: Boost CMake Workflow
uses: alandefreitas/cpp-actions/[email protected].2
uses: alandefreitas/cpp-actions/[email protected].7
if: ${{ matrix.coverage || matrix.time-trace || matrix.build-cmake || matrix.is-earliest }}
with:
source-dir: boost-root
Expand Down Expand Up @@ -977,7 +983,7 @@ jobs:
echo "LD_LIBRARY_PATH=$GITHUB_WORKSPACE/.local/lib:$LD_LIBRARY_PATH" >> "$GITHUB_ENV"

- name: Find Package Integration Workflow
uses: alandefreitas/cpp-actions/[email protected].2
uses: alandefreitas/cpp-actions/[email protected].7
if: ${{ matrix.build-cmake || matrix.is-earliest }}
with:
source-dir: boost-root/libs/${{ steps.patch.outputs.module }}/test/cmake_test
Expand All @@ -1001,7 +1007,7 @@ jobs:
toolchain: ${{ (startsWith(matrix.runs-on, 'windows') && steps.patch-user-config.outputs.toolchain) || '' }}

- name: Subdirectory Integration Workflow
uses: alandefreitas/cpp-actions/[email protected].2
uses: alandefreitas/cpp-actions/[email protected].7
if: ${{ matrix.build-cmake || matrix.is-earliest }}
with:
source-dir: boost-root/libs/${{ steps.patch.outputs.module }}/test/cmake_test
Expand All @@ -1022,7 +1028,7 @@ jobs:
toolchain: ${{ (startsWith(matrix.runs-on, 'windows') && steps.patch-user-config.outputs.toolchain) || '' }}

- name: Root Project CMake Workflow
uses: alandefreitas/cpp-actions/[email protected].2
uses: alandefreitas/cpp-actions/[email protected].7
if: ${{ matrix.build-cmake || matrix.is-earliest }}
with:
source-dir: boost-root/libs/${{ steps.patch.outputs.module }}
Expand All @@ -1046,7 +1052,7 @@ jobs:
toolchain: ${{ (startsWith(matrix.runs-on, 'windows') && steps.patch-user-config.outputs.toolchain) || '' }}

- name: FlameGraph
uses: alandefreitas/cpp-actions/[email protected].2
uses: alandefreitas/cpp-actions/[email protected].7
if: matrix.time-trace
with:
source-dir: boost-root/libs/http_proto
Expand Down Expand Up @@ -1099,7 +1105,7 @@ jobs:
fetch-depth: 100

- name: Changelog
uses: alandefreitas/cpp-actions/[email protected].2
uses: alandefreitas/cpp-actions/[email protected].7
with:
thank-non-regular: ${{ startsWith(github.ref, 'refs/tags/') }}
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -1118,7 +1124,7 @@ jobs:
node-version: 18

- name: Setup C++
uses: alandefreitas/cpp-actions/[email protected].2
uses: alandefreitas/cpp-actions/[email protected].7
id: setup-cpp
with:
compiler: clang
Expand Down
1 change: 0 additions & 1 deletion include/boost/http_proto/detail/impl/workspace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ struct alignas(alignof(::max_align_t))
{
U u;

any_impl() = delete;
any_impl(any_impl const&) = delete;
any_impl(any_impl&&) = delete;

Expand Down
55 changes: 4 additions & 51 deletions include/boost/http_proto/serializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
#ifndef BOOST_HTTP_PROTO_SERIALIZER_HPP
#define BOOST_HTTP_PROTO_SERIALIZER_HPP

#include <boost/http_proto/detail/config.hpp>
#include <boost/http_proto/context.hpp>
#include <boost/http_proto/source.hpp>
#include <boost/http_proto/detail/array_of_buffers.hpp>
#include <boost/http_proto/detail/config.hpp>
#include <boost/http_proto/detail/except.hpp>
#include <boost/http_proto/detail/header.hpp>
#include <boost/http_proto/detail/workspace.hpp>
#include <boost/http_proto/source.hpp>
#include <boost/buffers/circular_buffer.hpp>
#include <boost/buffers/const_buffer_span.hpp>
#include <boost/buffers/range.hpp>
#include <boost/buffers/type_traits.hpp>
#include <boost/system/result.hpp>
Expand Down Expand Up @@ -68,7 +69,7 @@ class BOOST_SYMBOL_VISIBLE
serializer
{
public:
class const_buffers_type;
using const_buffers_type = buffers::const_buffer_span;

struct stream;

Expand Down Expand Up @@ -509,54 +510,6 @@ struct serializer::stream

//---------------------------------------------------------

/** A ConstBufferSequence representing the output
*/
class serializer::
const_buffers_type
{
std::size_t n_ = 0;
buffers::const_buffer const* p_ = nullptr;

friend class serializer;

const_buffers_type(
buffers::const_buffer const* p,
std::size_t n) noexcept
: n_(n)
, p_(p)
{
}

public:
using iterator = buffers::const_buffer const*;
using const_iterator = iterator;
using value_type = buffers::const_buffer;
using reference = buffers::const_buffer;
using const_reference = buffers::const_buffer;
using size_type = std::size_t;
using difference_type = std::ptrdiff_t;

const_buffers_type() = default;
const_buffers_type(
const_buffers_type const&) = default;
const_buffers_type& operator=(
const_buffers_type const&) = default;

iterator
begin() const noexcept
{
return p_;
}

iterator
end() const noexcept
{
return p_ + n_;
}
};

//------------------------------------------------

template<
class ConstBufferSequence,
class>
Expand Down
4 changes: 0 additions & 4 deletions src/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,10 +397,6 @@ parser_service(
//if(cfg.min_prepare > cfg.max_prepare)
//detail::throw_invalid_argument();

if( cfg.min_buffer < 1 ||
cfg.min_buffer > cfg.body_limit)
detail::throw_invalid_argument();

if(cfg.max_prepare < 1)
detail::throw_invalid_argument();

Expand Down
Loading
Loading