Skip to content
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ is built as a standalone project and consumes the installed package through
custom builds.
- [vcpkg](https://github.com/microsoft/vcpkg), bootstrapped locally, required
for the provided presets.
- Ninja for the provided Linux presets.
- Ninja 1.10.2 or newer for the provided Linux presets.
- A multilib toolchain and 32-bit development libraries for Linux x86 builds.
- Python 3 and gcovr 8.6 for coverage generation.

Expand Down
6 changes: 4 additions & 2 deletions docker/linux-clang-x64.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ FROM ubuntu:22.04

ARG DEBIAN_FRONTEND=noninteractive
ARG CMAKE_VERSION=4.4.2
ARG NINJA_VERSION=1.11.1.1
ARG VCPKG_COMMIT=6f29f12e82a8293156836ad81cc9bf5af41fe836

RUN apt-get update \
Expand All @@ -15,7 +16,6 @@ RUN apt-get update \
git \
lld \
llvm \
ninja-build \
pkg-config \
python3 \
python3-pip \
Expand All @@ -24,7 +24,9 @@ RUN apt-get update \
zip \
&& rm -rf /var/lib/apt/lists/*

RUN python3 -m pip install --no-cache-dir "cmake==${CMAKE_VERSION}"
RUN python3 -m pip install --no-cache-dir \
"cmake==${CMAKE_VERSION}" \
"ninja==${NINJA_VERSION}"

RUN git clone https://github.com/microsoft/vcpkg.git /opt/vcpkg \
&& git -C /opt/vcpkg checkout --detach "${VCPKG_COMMIT}" \
Expand Down
6 changes: 4 additions & 2 deletions docker/linux-clang-x86.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ FROM ubuntu:22.04

ARG DEBIAN_FRONTEND=noninteractive
ARG CMAKE_VERSION=4.4.2
ARG NINJA_VERSION=1.11.1.1
ARG VCPKG_COMMIT=6f29f12e82a8293156836ad81cc9bf5af41fe836

RUN apt-get update \
Expand All @@ -17,7 +18,6 @@ RUN apt-get update \
git \
lld \
llvm \
ninja-build \
pkg-config \
python3 \
python3-pip \
Expand All @@ -26,7 +26,9 @@ RUN apt-get update \
zip \
&& rm -rf /var/lib/apt/lists/*

RUN python3 -m pip install --no-cache-dir "cmake==${CMAKE_VERSION}"
RUN python3 -m pip install --no-cache-dir \
"cmake==${CMAKE_VERSION}" \
"ninja==${NINJA_VERSION}"

RUN git clone https://github.com/microsoft/vcpkg.git /opt/vcpkg \
&& git -C /opt/vcpkg checkout --detach "${VCPKG_COMMIT}" \
Expand Down
5 changes: 3 additions & 2 deletions docker/linux-gcc-x64.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ FROM ubuntu:22.04
ARG DEBIAN_FRONTEND=noninteractive
ARG CMAKE_VERSION=4.4.2
ARG GCOVR_VERSION=8.6
ARG NINJA_VERSION=1.11.1.1
ARG VCPKG_COMMIT=6f29f12e82a8293156836ad81cc9bf5af41fe836

RUN apt-get update \
Expand All @@ -13,7 +14,6 @@ RUN apt-get update \
ca-certificates \
curl \
git \
ninja-build \
pkg-config \
python3 \
python3-pip \
Expand All @@ -24,7 +24,8 @@ RUN apt-get update \

RUN python3 -m pip install --no-cache-dir \
"cmake==${CMAKE_VERSION}" \
"gcovr==${GCOVR_VERSION}"
"gcovr==${GCOVR_VERSION}" \
"ninja==${NINJA_VERSION}"

RUN git clone https://github.com/microsoft/vcpkg.git /opt/vcpkg \
&& git -C /opt/vcpkg checkout --detach "${VCPKG_COMMIT}" \
Expand Down
6 changes: 4 additions & 2 deletions docker/linux-gcc-x86.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ FROM ubuntu:22.04

ARG DEBIAN_FRONTEND=noninteractive
ARG CMAKE_VERSION=4.4.2
ARG NINJA_VERSION=1.11.1.1
ARG VCPKG_COMMIT=6f29f12e82a8293156836ad81cc9bf5af41fe836

RUN apt-get update \
Expand All @@ -14,7 +15,6 @@ RUN apt-get update \
g++-multilib \
gcc-multilib \
git \
ninja-build \
pkg-config \
python3 \
python3-pip \
Expand All @@ -23,7 +23,9 @@ RUN apt-get update \
zip \
&& rm -rf /var/lib/apt/lists/*

RUN python3 -m pip install --no-cache-dir "cmake==${CMAKE_VERSION}"
RUN python3 -m pip install --no-cache-dir \
"cmake==${CMAKE_VERSION}" \
"ninja==${NINJA_VERSION}"

RUN git clone https://github.com/microsoft/vcpkg.git /opt/vcpkg \
&& git -C /opt/vcpkg checkout --detach "${VCPKG_COMMIT}" \
Expand Down
6 changes: 3 additions & 3 deletions docs/build-and-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ Every build requires:
- platform thread support.

GoogleTest is required only when `BUILD_TESTING=ON`. The recommended Linux
presets use Ninja. Linux x86 builds additionally require a multilib compiler
and 32-bit system development libraries.
presets use Ninja 1.10.2 or newer. Linux x86 builds additionally require a
multilib compiler and 32-bit system development libraries.

The current CI toolchains are MSVC v143, GCC 11, and Clang 14. These versions
define the continuously tested configurations, not a hard requirement for a
Expand Down Expand Up @@ -369,7 +369,7 @@ architectures, standard-library ABIs, or MSVC runtime models.

- Confirm that `VCPKG_ROOT` is set in the environment visible to CMake or the
IDE, not only in a different terminal session.
- Install Ninja before selecting a provided Linux preset.
- Install Ninja 1.10.2 or newer before selecting a provided Linux preset.
- Use a fresh build directory after changing the compiler, generator,
architecture, toolchain, or vcpkg triplet.
- Ensure the package architecture and configuration match the consumer.
Expand Down
12 changes: 7 additions & 5 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ distribution. Package names may differ on other distributions.

### 1. Install the tools

Install the compiler, Ninja, Git, Python, and the utilities needed by vcpkg:
Install the compiler, Git, Python, and the utilities needed by vcpkg:

```bash
sudo apt-get update
Expand All @@ -131,7 +131,6 @@ sudo apt-get install --yes \
ca-certificates \
curl \
git \
ninja-build \
pkg-config \
python3 \
python3-pip \
Expand All @@ -140,11 +139,14 @@ sudo apt-get install --yes \
zip
```

Ubuntu 22.04 provides an older CMake than this project requires. One way to
install a sufficiently recent user-local version is:
Ubuntu 22.04 provides older CMake and Ninja versions than the recommended
project setup. Install the same versions used by the Linux toolchain images in
the user-local Python binary directory:

```bash
python3 -m pip install --user "cmake==4.4.2"
python3 -m pip install --user \
"cmake==4.4.2" \
"ninja==1.11.1.1"
export PATH="$HOME/.local/bin:$PATH"
```

Expand Down
46 changes: 36 additions & 10 deletions rpc-lib/rpc-lib/pipe/tcp-pipe/tcp-pipe-endpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,13 @@ namespace vshalygin::rpc {

void invalidate_unsafe(bool by_cancel);

void start_write_header_async();
void start_write_header_async(
std::vector<pending_write_result> &pending_results);
void start_write_payload_async(
std::vector<pending_write_result> &pending_results);

void start_read_header_async();
void start_read_header_async(
std::vector<pending_read_result> &pending_results);
void start_read_payload_async(
std::vector<pending_read_result> &pending_results);

Expand Down Expand Up @@ -338,6 +340,7 @@ namespace vshalygin::rpc {
assert(msg.size() != 0);

write_future future;
std::vector<pending_write_result> pending_results;
bool is_connected;
{
cl::ordered_lock guard(m_write_mtx, m_socket_mtx);
Expand Down Expand Up @@ -379,11 +382,13 @@ namespace vshalygin::rpc {
std::move(msg), std::move(promise), id, timer_id);

if(m_write_operations.size() == 1) {
start_write_header_async();
start_write_header_async(pending_results);
}
}
}

publish_results(pending_results);

if(!is_connected) {
return write_future(m_thread_pool, pipe_op_res::failed);
}
Expand All @@ -393,6 +398,7 @@ namespace vshalygin::rpc {
read_future tcp_pipe_endpoint::impl::read_async(const std::optional<std::chrono::milliseconds> &timeout)
{
read_future future;
std::vector<pending_read_result> pending_results;
bool is_connected;
{
cl::ordered_lock guard(m_read_mtx, m_socket_mtx);
Expand Down Expand Up @@ -434,21 +440,32 @@ namespace vshalygin::rpc {
m_read_operations.emplace_front(std::move(promise), id, timer_id);

if(m_read_operations.size() == 1) {
start_read_header_async();
start_read_header_async(pending_results);
}
}
}

publish_results(pending_results);

if(!is_connected) {
return read_future(m_thread_pool, cl::ftuple(pipe_op_res::failed, cl::buffer{}));
}
return future;
}

void tcp_pipe_endpoint::impl::start_write_header_async()
void tcp_pipe_endpoint::impl::start_write_header_async(
std::vector<pending_write_result> &pending_results)
{
assert(!m_write_operations.empty());
assert(m_socket.is_open());

if(!m_socket.is_open()) {
auto r = m_was_invalidated_by_fail
? pipe_op_res::failed
: pipe_op_res::canceled;
complete_all_operations_unsafe(
r, m_write_operations, pending_results);
return;
}

m_socket.async_write_some(m_write_operations.back().op.get_unwritten_header_buffer(),
[self = shared_from_this()](const boost::system::error_code &ec,
Expand Down Expand Up @@ -485,10 +502,19 @@ namespace vshalygin::rpc {
});
}

void tcp_pipe_endpoint::impl::start_read_header_async()
void tcp_pipe_endpoint::impl::start_read_header_async(
std::vector<pending_read_result> &pending_results)
{
assert(!m_read_operations.empty());
assert(m_socket.is_open());

if(!m_socket.is_open()) {
auto r = m_was_invalidated_by_fail
? pipe_op_res::failed
: pipe_op_res::canceled;
complete_all_operations_unsafe(
r, m_read_operations, pending_results);
return;
}

m_socket.async_read_some(m_read_operations.back().op.get_buffer_for_unread_header(),
[self = shared_from_this()](const boost::system::error_code &ec,
Expand Down Expand Up @@ -563,7 +589,7 @@ namespace vshalygin::rpc {
}
} else {
if(!op.is_header_completed()) {
(this->*start_header_op_async)();
(this->*start_header_op_async)(pending_results);
} else {
(this->*start_payload_op_async)(pending_results);
}
Expand Down Expand Up @@ -617,7 +643,7 @@ namespace vshalygin::rpc {
operations.pop_back();

if(!operations.empty()) {
(this->*start_header_op_async)();
(this->*start_header_op_async)(pending_results);
}
}
}
Expand Down