pw_rpc: Don't send response on client call moves
- Client-side calls were sending a RESPONSE packet when they were closed
during a move. Have MoveFrom require the current call to be closed and
take the appropriate action in the ServerCall or ClientCall.
- Expand client call tests to more thoroughly cover moves and going out
of scope.
- Replace the PW_DCHECK(active()) in Close() with an if (active()) check
Add a PW_DCHECK(!active()) in MoveFrom instead.
Change-Id: Id232d1172135ba5bb4ec3586d190a281bb734cba
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/66300
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Reviewed-by: Alexei Frolov <frolv@google.com>
diff --git a/pw_rpc/server_call.cc b/pw_rpc/server_call.cc
index 2308074..6ebb09e 100644
--- a/pw_rpc/server_call.cc
+++ b/pw_rpc/server_call.cc
@@ -17,6 +17,9 @@
namespace pw::rpc::internal {
ServerCall& ServerCall::operator=(ServerCall&& other) {
+ // If this call is active, finish it first.
+ CloseAndSendResponse(OkStatus()).IgnoreError();
+
MoveFrom(other);
#if PW_RPC_CLIENT_STREAM_END_CALLBACK