Compare commits

...

9 Commits

Author SHA1 Message Date
916dcf8eb3 Remove superfluous log messages from tests 2025-05-23 09:25:48 +03:30
07cc9a20bc docs: Remove moved sections 2025-05-23 09:25:48 +03:30
19c38c308a Replace detail/work_guard.hpp with net::executor_work_guard
In newer versions of Asio, `executor_work_guard<>` can be used even when
`ASIO_NO_TS_EXECUTORS` is defined.
2025-04-27 16:08:05 +03:30
78478557f6 Conditionally define immediate_executor_type in async_base
Fixes #3002
2025-04-27 16:08:05 +03:30
f60f7c152f added cstdint include 2025-04-26 22:09:35 +03:30
c5d20f50c5 Update .github/build.yml 2025-04-26 21:17:00 +03:30
1f3c4089ab Use handshake_timeout for closing handshake during read operations
Fixes #2999
2025-04-26 21:17:00 +03:30
1d8dfae490 Fix a typo in release notes 2025-03-26 15:45:36 +03:30
f1492dd164 Fix link to async_teardown in teardown document
Previously, this link incorrectly pointed to teardown instead of async_teardown.
2025-03-05 08:56:26 +03:30
25 changed files with 196 additions and 453 deletions

View File

@ -19,6 +19,7 @@ def main(ctx):
linux_cxx("GCC Valgrind", "g++", packages="g++-14 libssl-dev valgrind", image="cppalliance/droneubuntu2404:1", buildtype="boost_v1", buildscript="drone", environment={ "VARIANT": "beast_valgrind", "TOOLSET": "gcc", "COMPILER": "g++", "CXXSTD": "11" }, globalenv=globalenv),
linux_cxx("Default g++", "g++", packages="mlocate", image="cppalliance/droneubuntu1604:1", buildtype="boost_v1", buildscript="drone", environment={ "VARIANT": "release", "TOOLSET": "gcc", "COMPILER": "g++", "CXXSTD": "11" }, globalenv=globalenv),
linux_cxx("GCC 8, C++17, libstdc++, release", "g++-8", packages="g++-8 mlocate", image="cppalliance/droneubuntu1604:1", buildtype="boost_v1", buildscript="drone", environment={ "VARIANT": "release", "TOOLSET": "gcc", "COMPILER": "g++-8", "CXXSTD" : "17" }, globalenv=globalenv),
linux_cxx("GCC 14, -DBOOST_ASIO_NO_TS_EXECUTORS", "g++-14", packages="g++-14", image="cppalliance/droneubuntu2404:1", buildtype="boost_v1", buildscript="drone", environment={ "VARIANT": "release", "TOOLSET": "gcc", "COMPILER": "g++-14", "CXXSTD" : "20" , "CXX_FLAGS": "<cxxflags>-DBOOST_ASIO_NO_TS_EXECUTORS"}, globalenv=globalenv),
linux_cxx("Clang 18, UBasan", "clang++-18", packages="clang-18 libssl-dev", image="cppalliance/droneubuntu2404:1", buildtype="boost_v1", buildscript="drone", environment={"VARIANT": "beast_ubasan", "TOOLSET": "clang", "COMPILER": "clang++-18", "CXXSTD": "17", "UBSAN_OPTIONS": 'print_stacktrace=1', "DRONE_BEFORE_INSTALL": "UBasan" }, globalenv=globalenv, privileged=True),
linux_cxx("docs", "", packages="docbook docbook-xml docbook-xsl xsltproc libsaxonhe-java default-jre-headless flex libfl-dev bison unzip rsync mlocate", image="cppalliance/droneubuntu1804:1", buildtype="docs", buildscript="drone", environment={"COMMENT": "docs"}, globalenv=globalenv),
linux_cxx("GCC 14, UBasan", "g++-14", packages="g++-14", buildtype="boost", buildscript="drone", image="cppalliance/droneubuntu2404:1", environment={'COMMENT': 'ubsan', 'B2_VARIANT': 'debug', 'B2_TOOLSET': 'gcc-14', 'B2_CXXSTD': '14,17,20,23', 'B2_UBSAN': '1', 'B2_DEFINES': 'BOOST_NO_STRESS_TEST=1', 'B2_LINKFLAGS': '-fuse-ld=gold'}, globalenv=globalenv, privileged=True),

View File

@ -11,7 +11,6 @@ env:
jobs:
runner-selection:
# runs-on: ubuntu-latest
runs-on: ${{ github.repository_owner == 'boostorg' && fromJSON('[ "self-hosted", "linux", "x64", "ubuntu-latest-aws" ]') || 'ubuntu-latest' }}
outputs:
labelmatrix: ${{ steps.aws_hosted_runners.outputs.labelmatrix }}
@ -21,7 +20,6 @@ jobs:
uses: cppalliance/aws-hosted-runners@v1.0.0
posix:
if: true
defaults:
run:
shell: bash
@ -31,199 +29,177 @@ jobs:
matrix:
include:
- toolset: gcc-5
cxxstd: "11,14,1z"
os: ubuntu-22.04
cxxstd: 11,14,1z
os: ubuntu-24.04
container: ubuntu:16.04
install: g++-5
supported: true
- toolset: gcc-6
cxxstd: "11,14,1z"
os: ubuntu-22.04
container: ubuntu:16.04
cxxstd: 11,14,1z
os: ubuntu-24.04
container: ubuntu:18.04
install: g++-6
supported: true
- toolset: gcc-7
cxxstd: "11,14,17"
os: ubuntu-22.04
cxxstd: 11,14,17
os: ubuntu-24.04
container: ubuntu:18.04
install: g++-7
supported: true
- toolset: gcc-8
cxxstd: "11,14,17,2a"
os: ubuntu-22.04
cxxstd: 11,14,17,2a
os: ubuntu-24.04
container: ubuntu:18.04
install: g++-8
supported: true
- toolset: gcc-9
cxxstd: "11,14,17,2a"
os: ubuntu-22.04
container: ubuntu:18.04
cxxstd: 11,14,17,2a
os: ubuntu-24.04
container: ubuntu:20.04
install: g++-9
supported: true
- toolset: gcc-10
cxxstd: "11,14,17,2a"
cxxstd: 11,14,17,2a
os: ubuntu-22.04
install: g++-10
supported: true
- toolset: gcc-11
cxxstd: "11,14,17,20"
cxxstd: 11,14,17,20
os: ubuntu-22.04
install: g++-11
supported: true
- toolset: gcc-12
cxxstd: "11,14,17,20,2b"
cxxstd: 11,14,17,20,2b
os: ubuntu-22.04
install: g++-12
supported: true
- toolset: gcc-13
cxxstd: "11,14,17,20,2b"
cxxstd: 11,14,17,20,2b
os: ubuntu-24.04
install: g++-13
supported: true
- toolset: gcc-14
cxxstd: "11,14,17,20,2b"
cxxstd: 11,14,17,20,2b
os: ubuntu-24.04
install: g++-14
supported: true
# clang 3.5 not supported
# It can't compile the websocket stream code
- toolset: clang
compiler: clang++-3.5
cxxstd: 11
os: ubuntu-24.04
container: ubuntu:16.04
install: clang-3.5
- toolset: clang
compiler: clang++-3.6
cxxstd: "11,14"
os: ubuntu-22.04
cxxstd: 11,14
os: ubuntu-24.04
container: ubuntu:16.04
install: clang-3.6
supported: true
- toolset: clang
compiler: clang++-3.7
cxxstd: "11,14"
os: ubuntu-22.04
cxxstd: 11,14
os: ubuntu-24.04
container: ubuntu:16.04
install: clang-3.7
supported: true
- toolset: clang
compiler: clang++-3.8
cxxstd: "11,14"
os: ubuntu-22.04
cxxstd: 11,14
os: ubuntu-24.04
container: ubuntu:16.04
install: clang-3.8
supported: true
- toolset: clang
compiler: clang++-3.9
cxxstd: "11,14"
os: ubuntu-22.04
container: ubuntu:16.04
cxxstd: 11,14
os: ubuntu-24.04
container: ubuntu:18.04
install: clang-3.9
supported: true
- toolset: clang
compiler: clang++-4.0
cxxstd: "11,14"
os: ubuntu-22.04
container: ubuntu:16.04
cxxstd: 11,14
os: ubuntu-24.04
container: ubuntu:18.04
install: clang-4.0
supported: true
- toolset: clang
compiler: clang++-5.0
cxxstd: "11,14"
os: ubuntu-22.04
container: ubuntu:16.04
cxxstd: 11,14
os: ubuntu-24.04
container: ubuntu:18.04
install: clang-5.0
supported: true
- toolset: clang
install: clang-6.0
compiler: clang++-6.0
cxxstd: "11,14,17"
os: ubuntu-22.04
cxxstd: 11,14,17
os: ubuntu-24.04
container: ubuntu:18.04
supported: true
- toolset: clang
install: clang-7
compiler: clang++-7
cxxstd: "11,14"
os: ubuntu-22.04
cxxstd: 11,14
os: ubuntu-24.04
container: ubuntu:18.04
supported: true
- toolset: clang
install: clang-8
compiler: clang++-8
cxxstd: "11,14,17"
os: ubuntu-22.04
cxxstd: 11,14,17
os: ubuntu-24.04
container: ubuntu:18.04
supported: true
- toolset: clang
install: clang-9
compiler: clang++-9
cxxstd: "11,14,17,2a"
os: ubuntu-22.04
cxxstd: 11,14,17,2a
os: ubuntu-24.04
container: ubuntu:18.04
supported: true
- toolset: clang
install: clang-10
compiler: clang++-10
cxxstd: "11,14,17,2a"
os: ubuntu-20.04
supported: true
cxxstd: 11,14,17,2a
os: ubuntu-24.04
container: ubuntu:20.04
- toolset: clang
install: clang-11
compiler: clang++-11
cxxstd: "11,14,17,2a"
os: ubuntu-20.04
supported: true
cxxstd: 11,14,17,2a
os: ubuntu-24.04
container: ubuntu:20.04
- toolset: clang
install: clang-12
compiler: clang++-12
cxxstd: "11,14,17,20"
cxxstd: 11,14,17,20
os: ubuntu-22.04
supported: true
- toolset: clang
install: clang-13
compiler: clang++-13
cxxstd: "11,14,17,20"
cxxstd: 11,14,17,20
os: ubuntu-22.04
supported: true
- toolset: clang
install: clang-14
compiler: clang++-14
cxxstd: "11,14,17,20"
cxxstd: 11,14,17,20
os: ubuntu-22.04
supported: true
- toolset: clang
install: clang-15
compiler: clang++-15
cxxstd: "11,14,17,20,2b"
cxxstd: 11,14,17,20,2b
os: ubuntu-22.04
supported: true
- toolset: clang
install: clang-16
compiler: clang++-16
cxxstd: "11,14,17,20" # no 2b: https://github.com/llvm/llvm-project/issues/97842
cxxstd: 11,14,17,20 # no 2b: https://github.com/llvm/llvm-project/issues/97842
os: ubuntu-24.04
supported: true
- toolset: clang
install: clang-17
compiler: clang++-17
cxxstd: "11,14,17,20" # no 2b: https://github.com/llvm/llvm-project/issues/97842
cxxstd: 11,14,17,20 # no 2b: https://github.com/llvm/llvm-project/issues/97842
os: ubuntu-24.04
supported: true
- toolset: clang
install: clang-18
compiler: clang++-18
cxxstd: "11,14,17,20,2b"
cxxstd: 11,14,17,20,2b
os: ubuntu-24.04
- toolset: clang
install: clang-19
compiler: clang++-19
cxxstd: 11,14,17,20,2b
os: ubuntu-24.04
supported: true
# macos
- toolset: clang
os: macos-13
cxxstd: "11,14,17,20,2b"
supported: true
cxxstd: 11,14,17,20,2b
- toolset: clang
os: macos-14
cxxstd: "11,14,17,20,2b"
supported: true
cxxstd: 11,14,17,20,2b
- toolset: clang
os: macos-15
cxxstd: "11,14,17,20,2b"
supported: true
cxxstd: 11,14,17,20,2b
needs: [runner-selection]
runs-on: ${{ fromJSON(needs.runner-selection.outputs.labelmatrix)[matrix.os] }}
@ -235,20 +211,10 @@ jobs:
steps:
- name: Setup container environment
if: matrix.container != ''
if: matrix.container
run: |
apt-get -o Acquire::Retries=3 update && DEBIAN_FRONTEND=noninteractive apt-get -y install tzdata && apt-get -o Acquire::Retries=3 install -y sudo software-properties-common wget curl apt-transport-https make apt-file sudo unzip libssl-dev build-essential autotools-dev autoconf automake g++ libc++-helpers python ruby cpio gcc-multilib g++-multilib pkgconf python3 ccache libpython-dev locales
sudo apt-add-repository ppa:git-core/ppa
sudo apt-get -o Acquire::Retries=3 update && apt-get -o Acquire::Retries=3 -y install git
python_version=$(python3 -c 'import sys; print("{0.major}.{0.minor}".format(sys.version_info))')
if [[ ${python_version} =~ ^3\.[0-5]$ ]]; then
true
else
apt-get install -y python3-distutils
fi
sudo wget https://bootstrap.pypa.io/pip/$python_version/get-pip.py
sudo python3 get-pip.py
sudo /usr/local/bin/pip install cmake
apt-get update
apt-get -y install sudo python3 git g++ curl xz-utils
- name: Install nodejs20glibc2.17
if: ${{ startsWith( matrix.container, 'ubuntu:1' ) }}
@ -256,25 +222,17 @@ jobs:
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
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install packages
if: matrix.install
run: |
for i in {1..3}; do sudo -E apt-add-repository -y "ppa:ubuntu-toolchain-r/test" && break || sleep 2; done
sudo apt-get update
sudo apt-get install -y ${{matrix.install}}
sudo apt-get install -y ${{matrix.install}} libssl-dev
- name: Setup Boost
shell: bash
run: |
if [[ $(uname) =~ [Ll]inux ]]; then
echo Installing locales for ${TRAVIS_OS_NAME} ...
sudo /usr/sbin/locale-gen fr_FR
sudo /usr/sbin/locale-gen en_GB
sudo locale -a
echo ...done with locales
fi
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
@ -291,162 +249,87 @@ jobs:
cd boost-root
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
python3 tools/boostdep/depinst/depinst.py $LIBRARY
./bootstrap.sh
./b2 -d0 headers
- name: Create user-config.jam
if: matrix.compiler
run: |
echo "using ${{matrix.toolset}} : : ${{matrix.compiler}} ;" >> ~/user-config.jam
echo "using ${{matrix.toolset}} : : ${{matrix.compiler}} ;" > ~/user-config.jam
- name: Run tests
shell: bash
run: |
cd ../boost-root
if [[ "${{matrix.supported}}" != "true" ]] ; then
echo "This configuration is not supported because ${{matrix.supported}}"
exit 0
fi
toolsets=$(sed 's/,/ /g' <<<"${{matrix.toolset}}")
standards=$(sed 's/,/ /g' <<<"${{matrix.cxxstd}}")
variants="debug release"
err=0
cd libs/$LIBRARY
for toolset in ${toolsets} ; do
for standard in ${standards} ; do
for variant in ${variants} ; do
if [[ err -ne 0 ]] ; then
echo "skipping: ${toolset} ${standard} ${variant}"
else
echo "running: ${toolset} ${standard} ${variant}"
../../b2 test toolset=${toolset} cxxstd=${standard} variant=${variant}
err=$?
fi
done
done
done
[[ $err -ne 0 ]] && false || true
./b2 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} variant=debug,release
windows:
if: true
strategy:
fail-fast: false
matrix:
include:
- description: msvc-14.2-cxx14-win32
toolset: msvc-14.2
cxxstd: "14"
- toolset: msvc-14.2
cxxstd: 14,17
addrmd: 32
os: windows-2019
cxxflags: ""
supported: true
- description: msvc-14.2-cxx17-win32
toolset: msvc-14.2
cxxstd: "17"
- toolset: msvc-14.2
cxxstd: 20,latest
addrmd: 32
os: windows-2019
cxxflags: "cxxflags=-D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING=1"
supported: true
- description: msvc-14.2-cxx20-win32
toolset: msvc-14.2
cxxstd: "latest"
addrmd: 32
os: windows-2019
cxxflags: "cxxflags=-D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING=1"
supported: true
- description: msvc-14.2-cxx14-win64
toolset: msvc-14.2
cxxstd: "14"
- toolset: msvc-14.2
cxxstd: 14,17
addrmd: 64
os: windows-2019
cxxflags: ""
supported: true
- description: msvc-14.2-cxx17-win64
toolset: msvc-14.2
cxxstd: "17"
- toolset: msvc-14.2
cxxstd: 20,latest
addrmd: 64
os: windows-2019
cxxflags: "cxxflags=-D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING=1"
supported: true
- description: msvc-14.2-cxx20-win64
toolset: msvc-14.2
cxxstd: "latest"
addrmd: 64
os: windows-2019
cxxflags: "cxxflags=-D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING=1"
supported: true
- description: msvc-14.3-cxx14-win32
toolset: msvc-14.3
cxxstd: "14"
- toolset: msvc-14.3
cxxstd: 14,17
addrmd: 32
os: windows-2022
cxxflags: ""
supported: true
- description: msvc-14.3-cxx17-win32
toolset: msvc-14.3
cxxstd: "17"
- toolset: msvc-14.3
cxxstd: 20,latest
addrmd: 32
os: windows-2022
cxxflags: "cxxflags=-D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING=1"
supported: true
- description: msvc-14.3-cxx20-win32
toolset: msvc-14.3
cxxstd: "20"
- toolset: msvc-14.3
cxxstd: 14,17
addrmd: 64
os: windows-2022
- toolset: msvc-14.3
cxxstd: 20,latest
addrmd: 64
os: windows-2022
- toolset: clang-win
cxxstd: 14,17,latest
addrmd: 32
os: windows-2022
cxxflags: "cxxflags=-D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING=1"
supported: true
- description: msvc-14.3-cxx14-win64
toolset: msvc-14.3
cxxstd: "14"
cxxflags: "linkflags=/safeseh:no"
- toolset: clang-win
cxxstd: 14,17,latest
addrmd: 64
os: windows-2022
cxxflags: ""
supported: true
- description: msvc-14.3-cxx17-win64
toolset: msvc-14.3
cxxstd: "17"
addrmd: 64
os: windows-2022
cxxflags: "cxxflags=-D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING=1"
supported: true
- description: msvc-14.3-cxx20-win64
toolset: msvc-14.3
cxxstd: "20"
addrmd: 64
os: windows-2022
cxxflags: "cxxflags=-D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING=1"
supported: true
- toolset: gcc
cxxstd: "11,14,17,2a"
addrmd: 64
os: windows-2019
cxxflags: "cxxflags=-Wa,-mbig-obj"
supported: "Too many unknowns to get this compiler working - gcc-8.1"
needs: [runner-selection]
runs-on: ${{ fromJSON(needs.runner-selection.outputs.labelmatrix)[matrix.os] }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup OpenSSL
shell: cmd
run: |
if "${{matrix.addrmd}}" == "64" (
choco install --no-progress -y openssl --x64 --version=3.1.1
choco install --no-progress -y openssl --version 3.1.1
)
if "${{matrix.addrmd}}" == "32" (
; as of 17.08.23 openssl 3 doesn't support x86
set openssl_install_dir="C:\\Program Files (x86)\\OpenSSL-Win32"
choco install --no-progress -y openssl --forcex86 --version=1.1.1.2100
choco install --no-progress -y openssl --forcex86 --version 1.1.1.2100
)
if "${{matrix.addrmd}}" == "64" (
if exist "C:\Program Files\OpenSSL\" (
set openssl_install_dir="C:\\Program Files\\OpenSSL"
set openssl_install_dir="C:\\Program Files\\OpenSSL"
) else (
set openssl_install_dir="C:\\Program Files\\OpenSSL-Win64"
set openssl_install_dir="C:\\Program Files\\OpenSSL-Win64"
)
)
mklink /D C:\OpenSSL %openssl_install_dir%
@ -477,36 +360,16 @@ jobs:
b2 -d0 headers
- name: Run tests
shell: bash
shell: cmd
run: |
echo "current directory: $(pwd)"
cd ../boost-root
if [[ "${{matrix.supported}}" != "true" ]] ; then
echo "This configuration is not supported because ${{matrix.supported}}"
exit 0
fi
toolsets=$(sed 's/,/ /g' <<<"${{matrix.toolset}}")
standards=$(sed 's/,/ /g' <<<"${{matrix.cxxstd}}")
address_models=$(sed 's/,/ /g' <<<"${{matrix.addrmd}}")
variants="debug release"
cd libs/$LIBRARY
for toolset in ${toolsets} ; do
for standard in ${standards} ; do
for address_model in ${address_models} ; do
for variant in ${variants} ; do
echo "running: ${toolset} ${standard} ${address_model} ${variant}"
../../b2 ${{matrix.cxxflags}} test toolset=${toolset} cxxstd=${standard} address-model=${address_model} variant=${variant} || exit $?
done
done
done
done
b2 -j3 libs/%LIBRARY%/test ${{matrix.cxxflags}} toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release
posix-cmake-subdir:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
- os: ubuntu-22.04
- os: ubuntu-24.04
- os: macos-13
@ -555,7 +418,6 @@ jobs:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
- os: ubuntu-22.04
- os: ubuntu-24.04
- os: macos-13
@ -614,7 +476,6 @@ jobs:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
- os: ubuntu-22.04
- os: ubuntu-24.04
- os: macos-13

View File

@ -5,7 +5,7 @@ Version 357:
* Updated SSL examples to verify peer certificate hostname
* Improved documentation of `websocket::stream::async_close`
* WebSockets: Peer pings are counted as activity for `idle_timeout`
* Fixed out-of-band access issue in `iequals` function
* Fixed out-of-bounds access in `iequals` function
* Removed Boost.Scope dependency from examples
* Refactored CMakeLists

View File

@ -1,6 +1,6 @@
#
# Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
# Copyright (c) 2021 DMitry Arkhipov (grisumbras@gmail.com)
# Copyright (c) 2021 Dmitry Arkhipov (grisumbras@gmail.com)
# Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
# Copyright (c) 2024 Mohammad Nejati
#

View File

@ -2,4 +2,4 @@
include(${CMAKE_CURRENT_LIST_DIR}/common.cmake)
# Compiler options.
add_compile_options(-Wall -Wextra -Wpedantic -Wno-unused-parameter)
add_compile_options(-Wall -Wextra -Wpedantic)

View File

@ -28,7 +28,7 @@ as free functions associated with the next layer type:
* [link beast.ref.boost__beast__websocket__teardown `teardown`]: Overloads
of this function drain and shut down a stream synchronously.
* [link beast.ref.boost__beast__websocket__teardown `async_teardown`]:
* [link beast.ref.boost__beast__websocket__async_teardown `async_teardown`]:
Overloads of this function drain and shut down a stream asynchronously.
The implementation provides suitable overloads of the teardown

View File

@ -197,11 +197,4 @@ __new__ indicates an item that was recently added.
[include 07_concepts/_concepts.qbk]
[include 08_design/_design.qbk]
[section:moved1 Release Notes (Moved)]
The Release Notes have been moved to the top of the table of contents.
[endsect]
[section:moved2 Reference (Moved)]
The Reference has been moved to the top of the table of contents.
[endsect]
[xinclude index.xml]

View File

@ -15,7 +15,7 @@
[*Fixes]
* [issue 2962] Fixed out-of-band access issue in `iequals` function
* [issue 2962] Fixed out-of-bounds access in `iequals` function
[*Improvements]

View File

@ -362,8 +362,7 @@ net::awaitable<void, executor_type>
run_websocket_session(
Stream& stream,
beast::flat_buffer& buffer,
http::request<http::string_body> req,
beast::string_view doc_root)
http::request<http::string_body> req)
{
auto cs = co_await net::this_coro::cancellation_state;
auto ws = websocket::stream<Stream&>{ stream };
@ -438,7 +437,7 @@ run_session(
beast::get_lowest_layer(stream).expires_never();
co_await run_websocket_session(
stream, buffer, parser.release(), doc_root);
stream, buffer, parser.release());
co_return;
}
@ -581,7 +580,9 @@ handle_signals(task_group& task_group)
}
else // SIGTERM
{
executor.get_inner_executor().context().stop();
net::query(
executor.get_inner_executor(),
net::execution::context).stop();
}
}

View File

@ -17,6 +17,7 @@
#include <boost/asio/append.hpp>
#include <boost/asio/associated_cancellation_slot.hpp>
#include <boost/asio/dispatch.hpp>
#include <boost/asio/executor_work_guard.hpp>
#include <boost/asio/post.hpp>
#include <mutex>
#include <stdexcept>
@ -57,13 +58,8 @@ class basic_stream<Executor>::read_op : public detail::stream_read_op_base
Handler h_;
boost::weak_ptr<detail::stream_state> wp_;
Buffers b_;
#if defined(BOOST_ASIO_NO_TS_EXECUTORS)
net::any_io_executor wg2_;
#else // defined(BOOST_ASIO_NO_TS_EXECUTORS)
net::executor_work_guard<
net::associated_executor_t<Handler, net::any_io_executor>> wg2_;
#endif // defined(BOOST_ASIO_NO_TS_EXECUTORS)
lambda(lambda&&) = default;
lambda(lambda const&) = default;
@ -75,15 +71,7 @@ class basic_stream<Executor>::read_op : public detail::stream_read_op_base
: h_(std::forward<Handler_>(h))
, wp_(s)
, b_(b)
#if defined(BOOST_ASIO_NO_TS_EXECUTORS)
, wg2_(net::prefer(
net::get_associated_executor(
h_, s->exec),
net::execution::outstanding_work.tracked))
#else // defined(BOOST_ASIO_NO_TS_EXECUTORS)
, wg2_(net::get_associated_executor(
h_, s->exec))
#endif // defined(BOOST_ASIO_NO_TS_EXECUTORS)
, wg2_(net::get_associated_executor(h_, s->exec))
{
}
@ -131,24 +119,14 @@ class basic_stream<Executor>::read_op : public detail::stream_read_op_base
}
}
#if defined(BOOST_ASIO_NO_TS_EXECUTORS)
net::dispatch(wg2_,
net::append(std::move(h_), ec, bytes_transferred));
wg2_ = net::any_io_executor(); // probably unnecessary
#else // defined(BOOST_ASIO_NO_TS_EXECUTORS)
net::dispatch(wg2_.get_executor(),
net::append(std::move(h_), ec, bytes_transferred));
wg2_.reset();
#endif // defined(BOOST_ASIO_NO_TS_EXECUTORS)
}
};
lambda fn_;
#if defined(BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
net::executor_work_guard<net::any_io_executor> wg1_;
#else
net::any_io_executor wg1_;
#endif
public:
template<class Handler_>
@ -157,25 +135,15 @@ public:
boost::shared_ptr<detail::stream_state> const& s,
Buffers const& b)
: fn_(std::forward<Handler_>(h), s, b)
#if defined(BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
, wg1_(s->exec)
#else
, wg1_(net::prefer(s->exec,
net::execution::outstanding_work.tracked))
#endif
{
}
void
operator()(error_code ec) override
{
#if defined(BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
net::post(wg1_.get_executor(), net::append(std::move(fn_), ec));
wg1_.reset();
#else
net::post(wg1_, net::append(std::move(fn_), ec));
wg1_ = net::any_io_executor(); // probably unnecessary
#endif
}
};

View File

@ -19,7 +19,6 @@
#include <boost/asio/async_result.hpp>
#include <boost/asio/buffer.hpp>
#include <boost/asio/error.hpp>
#include <boost/asio/executor_work_guard.hpp>
#include <boost/asio/any_io_executor.hpp>
#include <boost/asio/io_context.hpp>
#include <boost/assert.hpp>

View File

@ -14,7 +14,6 @@
#include <boost/beast/core/detail/allocator.hpp>
#include <boost/beast/core/detail/async_base.hpp>
#include <boost/beast/core/detail/filtering_cancellation_slot.hpp>
#include <boost/beast/core/detail/work_guard.hpp>
#include <boost/asio/append.hpp>
#include <boost/asio/associated_allocator.hpp>
#include <boost/asio/associated_cancellation_slot.hpp>
@ -22,6 +21,7 @@
#include <boost/asio/associated_immediate_executor.hpp>
#include <boost/asio/bind_executor.hpp>
#include <boost/asio/dispatch.hpp>
#include <boost/asio/executor_work_guard.hpp>
#include <boost/asio/handler_continuation_hook.hpp>
#include <boost/asio/post.hpp>
#include <boost/core/exchange.hpp>
@ -177,7 +177,8 @@ template<
>
class async_base
#if ! BOOST_BEAST_DOXYGEN
: private boost::empty_value<Allocator>
: public detail::with_immediate_executor_type<Handler>
, private boost::empty_value<Allocator>
#endif
{
static_assert(
@ -185,7 +186,7 @@ class async_base
"Executor type requirements not met");
Handler h_;
detail::select_work_guard_t<Executor1> wg1_;
net::executor_work_guard<Executor1> wg1_;
net::cancellation_type act_{net::cancellation_type::terminal};
public:
/** The type of executor associated with this object.
@ -193,7 +194,7 @@ public:
If a class derived from @ref boost::beast::async_base is a completion
handler, then the associated executor of the derived class will
be this type.
*/
*/
using executor_type =
#if BOOST_BEAST_DOXYGEN
__implementation_defined__;
@ -201,7 +202,7 @@ public:
typename
net::associated_executor<
Handler,
typename detail::select_work_guard_t<Executor1>::executor_type
typename net::executor_work_guard<Executor1>::executor_type
>::type;
#endif
@ -210,19 +211,12 @@ public:
If a class derived from @ref boost::beast::async_base is a completion
handler, then the associated immediage executor of the derived class will
be this type.
*/
using immediate_executor_type =
*/
#if BOOST_BEAST_DOXYGEN
using immediate_executor_type =
__implementation_defined__;
#else
typename
net::associated_immediate_executor<
Handler,
typename detail::select_work_guard_t<Executor1>::executor_type
>::type;
#endif
private:
virtual
@ -266,7 +260,7 @@ public:
Handler_&& handler,
Executor1 const& ex1)
: h_(std::forward<Handler_>(handler))
, wg1_(detail::make_work_guard(ex1))
, wg1_(ex1)
{
}
@ -333,7 +327,9 @@ public:
handler, then the object returned from this function will be used
as the associated immediate executor of the derived class.
*/
immediate_executor_type
net::associated_immediate_executor_t<
Handler,
typename net::executor_work_guard<Executor1>::executor_type>
get_immediate_executor() const noexcept
{
return net::get_associated_immediate_executor(

View File

@ -10,7 +10,9 @@
#ifndef BOOST_BEAST_CORE_DETAIL_ASYNC_BASE_HPP
#define BOOST_BEAST_CORE_DETAIL_ASYNC_BASE_HPP
#include <boost/core/exchange.hpp>
#include <boost/beast/core/detail/type_traits.hpp>
#include <boost/asio/associated_immediate_executor.hpp>
namespace boost {
namespace beast {
@ -39,6 +41,18 @@ protected:
virtual void destroy() = 0;
};
template<typename Handler, typename = void>
struct with_immediate_executor_type
{
};
template<typename Handler>
struct with_immediate_executor_type<Handler,
void_t<typename Handler::immediate_executor_type>>
{
using immediate_executor_type = typename Handler::immediate_executor_type;
};
} // detail
} // beast
} // boost

View File

@ -11,6 +11,7 @@
#define BOOST_BEAST_DETAIL_CPU_INFO_HPP
#include <boost/config.hpp>
#include <cstdint>
#ifndef BOOST_BEAST_NO_INTRINSICS
# if defined(BOOST_MSVC) || ((defined(BOOST_GCC) || defined(BOOST_CLANG)) && defined(__SSE4_2__))

View File

@ -1,102 +0,0 @@
//
// Copyright (c) 2020 Richard Hodges (hodges.r@gmail.com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/beast
//
#ifndef BOOST_BEAST_CORE_DETAIL_WORK_GUARD_HPP
#define BOOST_BEAST_CORE_DETAIL_WORK_GUARD_HPP
#include <boost/asio/executor_work_guard.hpp>
#include <boost/asio/execution.hpp>
#include <boost/optional.hpp>
namespace boost {
namespace beast {
namespace detail {
template<class Executor, class Enable = void>
struct select_work_guard;
template<class Executor>
using select_work_guard_t = typename
select_work_guard<Executor>::type;
#if !defined(BOOST_ASIO_NO_TS_EXECUTORS)
template<class Executor>
struct select_work_guard
<
Executor,
typename std::enable_if
<
net::is_executor<Executor>::value
>::type
>
{
using type = net::executor_work_guard<Executor>;
};
#endif
template<class Executor>
struct execution_work_guard
{
using executor_type = typename std::decay<decltype(
net::prefer(std::declval<Executor const&>(),
net::execution::outstanding_work.tracked))>::type;
execution_work_guard(Executor const& exec)
: ex_(net::prefer(exec, net::execution::outstanding_work.tracked))
{
}
executor_type
get_executor() const noexcept
{
BOOST_ASSERT(ex_.has_value());
return *ex_;
}
void reset() noexcept
{
ex_.reset();
}
private:
boost::optional<executor_type> ex_;
};
template<class Executor>
struct select_work_guard
<
Executor,
typename std::enable_if
<
net::execution::is_executor<Executor>::value
#if defined(BOOST_ASIO_NO_TS_EXECUTORS)
|| net::is_executor<Executor>::value
#else
&& !net::is_executor<Executor>::value
#endif
>::type
>
{
using type = execution_work_guard<Executor>;
};
template<class Executor>
select_work_guard_t<Executor>
make_work_guard(Executor const& exec) noexcept
{
return select_work_guard_t<Executor>(exec);
}
}
}
}
#endif // BOOST_BEAST_CORE_DETAIL_WORK_GUARD_HPP

View File

@ -66,28 +66,15 @@ class saved_handler::impl final : public base
};
ebo_pair v_;
#if defined(BOOST_ASIO_NO_TS_EXECUTORS)
typename std::decay<decltype(net::prefer(std::declval<
net::associated_executor_t<Handler>>(),
net::execution::outstanding_work.tracked))>::type
wg2_;
#else // defined(BOOST_ASIO_NO_TS_EXECUTORS)
net::executor_work_guard<
net::associated_executor_t<Handler>> wg2_;
#endif // defined(BOOST_ASIO_NO_TS_EXECUTORS)
net::cancellation_slot slot_{net::get_associated_cancellation_slot(v_.h)};
public:
template<class Handler_>
impl(alloc_type const& a, Handler_&& h,
saved_handler * owner)
: base(owner), v_(a, std::forward<Handler_>(h))
#if defined(BOOST_ASIO_NO_TS_EXECUTORS)
, wg2_(net::prefer(
net::get_associated_executor(v_.h),
net::execution::outstanding_work.tracked))
#else // defined(BOOST_ASIO_NO_TS_EXECUTORS)
, wg2_(net::get_associated_executor(v_.h))
#endif // defined(BOOST_ASIO_NO_TS_EXECUTORS)
{
}

View File

@ -662,6 +662,7 @@ public:
}
impl.change_status(status::closing);
impl.update_timer(this->get_executor());
if(! impl.wr_close)
{

View File

@ -44,7 +44,7 @@ struct ex1_type
{
net::execution_context &
query(net::execution::context_t c) const noexcept
query(net::execution::context_t) const noexcept
{ return *reinterpret_cast<net::execution_context *>(&ex1ctx); }
net::execution::blocking_t
@ -52,23 +52,23 @@ struct ex1_type
{ return net::execution::blocking; };
net::execution::outstanding_work_t
query(net::execution::outstanding_work_t w) const noexcept
query(net::execution::outstanding_work_t) const noexcept
{ return net::execution::outstanding_work; }
ex1_type
require(net::execution::blocking_t::possibly_t b) const
require(net::execution::blocking_t::possibly_t) const
{ return *this; }
ex1_type
require(net::execution::blocking_t::never_t b) const
require(net::execution::blocking_t::never_t) const
{ return *this; };
ex1_type
prefer(net::execution::outstanding_work_t::untracked_t w) const
prefer(net::execution::outstanding_work_t::untracked_t) const
{ return *this; };
ex1_type
prefer(net::execution::outstanding_work_t::tracked_t w) const
prefer(net::execution::outstanding_work_t::tracked_t) const
{ return *this; };
template<class F>

View File

@ -69,6 +69,7 @@ public:
template<class F>
void execute(F&&) const {}
simple_executor prefer(net::execution::outstanding_work_t::tracked_t) const { return *this; }
simple_executor require(net::execution::blocking_t::never_t) const { return *this; };
#else
void* context() { return nullptr; }
void on_work_started() {}

View File

@ -139,7 +139,6 @@ public:
void
run() override
{
log << "sizeof(decorator)==" << sizeof(decorator) << "\n";
testDecorator();
}
};

View File

@ -14,6 +14,8 @@
#include <boost/beast/_experimental/test/tcp.hpp>
#include <boost/beast/core/flat_buffer.hpp>
#include <thread>
namespace boost {
namespace beast {
namespace websocket {
@ -163,10 +165,46 @@ public:
}
void
testIssue2999()
{
net::io_context ioc;
// Use handshake_timeout for the closing handshake,
// which can occur in websocket::stream::async_read_some.
stream<test::stream> ws1(ioc);
stream<test::stream> ws2(ioc);
test::connect(ws1.next_layer(), ws2.next_layer());
ws1.async_handshake("test", "/", test::success_handler());
ws2.async_accept(test::success_handler());
test::run(ioc);
flat_buffer b;
ws1.set_option(stream_base::timeout{
std::chrono::milliseconds(50),
stream_base::none(),
false});
// add a close frame to the input
ws1.next_layer().append(string_view{
"\x88\x00", 2});
ws1.async_read(b, test::fail_handler(
beast::error::timeout));
// limit the write buffer so that writing
// the close frame will not complete during
// the call to ioc.run_one()
ws1.next_layer().write_size(1);
ioc.run_one();
ioc.restart();
std::this_thread::sleep_for(
std::chrono::milliseconds(100));
test::run(ioc);
}
void
run() override
{
testTimeout();
testIssue2999();
}
};

View File

@ -189,11 +189,6 @@ public:
stream<test::stream&>>::value);
#endif
log << "sizeof(websocket::stream) == " <<
sizeof(websocket::stream<test::stream&>) << std::endl;
log << "sizeof(websocket::stream::impl_type) == " <<
sizeof(websocket::stream<test::stream&>::impl_type) << std::endl;
testOptions();
testJavadoc();
}

View File

@ -638,10 +638,6 @@ public:
void
run() override
{
log <<
"sizeof(deflate_stream) == " <<
sizeof(deflate_stream) << std::endl;
testDeflate(zlib_compressor);
testDeflate(beast_compressor);
testInvalidSettings(zlib_compressor);

View File

@ -637,9 +637,6 @@ public:
void
run() override
{
log <<
"sizeof(inflate_stream) == " <<
sizeof(inflate_stream) << std::endl;
testInflate(zlib_decompressor);
testInflate(beast_decompressor);
testInflateErrors(zlib_decompressor);

View File

@ -41,9 +41,7 @@ protected:
net::io_context ioc_;
private:
beast::detail::select_work_guard_t<
net::io_context::executor_type>
work_;
net::executor_work_guard<net::io_context::executor_type> work_;
std::vector<std::thread> threads_;
std::mutex m_;
std::condition_variable cv_;
@ -56,8 +54,7 @@ public:
explicit
enable_yield_to(std::size_t concurrency = 1)
: work_(beast::detail::make_work_guard(
ioc_.get_executor()))
: work_(ioc_.get_executor())
{
threads_.reserve(concurrency);
while(concurrency--)