Commit Graph

5 Commits

Author SHA1 Message Date
Alexei Frolov
86e05def88 pw_rpc: Add call IDs to protocol
This expands the RPC protocol to include an optional call_id field, used
to map server->client packets to the client call object that made them.
This fixes an issue where a reinvoked call could receive a response
intended for the original invocation, with potentially stale data.

This feature is opt-in for RPC clients. Setting all call_ids to the same
number (such as the proto3 default 0) results in the previous client
behavior. Therefore, it is backwards compatible with all existing RPC
clients.

Change-Id: I6f1894afd491e6308dca5c31ae1704af920381c6
Requires: pigweed-internal:16840
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/66064
Commit-Queue: Alexei Frolov <frolv@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
2021-10-20 03:56:59 +00:00
Wyatt Hepler
31cace358d pw_transfer: Prevent receiver from requesting 0 bytes
- On Write transfers, abort with RESOURCE_EXHAUSTED if
  ConservativeWriteLimit() returns 0. Previously, transfers would stall
  since the client would set pending_bytes to 0.
- Use UNAVAILABLE (rather than RESOURCE_EXHAUSTED) to indicate that the
  service is busy and cannot start a new transfer.
- Abort transfers in the Python client if pending_bytes is 0.
- Enforce maximum values for pending_bytes and max_chunk_size_bytes in
  both Read and Write transfers.

Change-Id: If2f4346aa0f07382a0588c8110a815ad8607fcce
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/64024
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Commit-Queue: Wyatt Hepler <hepler@google.com>
2021-10-06 17:14:59 +00:00
Wyatt Hepler
e6209d9e14 pw_transfer: Reorganize code; ignore bad chunks after drops
- On writes, only send a transfer parameters update after the first
  chunk with an incorrect offset. This prevents storms of transfer
  parameters updates when early packets in the window are dropped. If
  that update is dropped, the client time out and resend its last chunk.
- Move transfer logic to the ServerContext class.
- Introduce the ClientConnection class, which represents a connection
  to a particular pw_transfer client. It bundles the server writers with
  the transfer parameters for those streams.

Change-Id: If68943610252c63c3044956f335a641523a8a917
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/63284
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Commit-Queue: Wyatt Hepler <hepler@google.com>
2021-10-02 01:05:06 +00:00
Alexei Frolov
ff057e8ff9 pw_transfer: Start C++ client
This starts an implementation of a C++ transfer client suitable for
device to device transfers. Both read and write transfer support is
added. The code is incomplete and untested; pw_rpc raw clients are
required before this can be functional.

Change-Id: I17154c50986f7de8027fbc4e0143e86e3c64dd64
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/61792
Commit-Queue: Alexei Frolov <frolv@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
2021-09-28 00:16:04 +00:00
Alexei Frolov
563946f9fa pw_transfer: C++ service write support
This adds support for client-to-server write transfers to the C++
transfer service. Additionally, the transfer service is updated to
require the maximum chunk size as a constructor argument, as this
cannot easily be determined from the RPC system.

Change-Id: I8a6beb452ae3b8166702972182a418dd3cf13514
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/56248
Reviewed-by: Wyatt Hepler <hepler@google.com>
2021-08-18 20:11:21 +00:00