From 4bbfa84c2d94ee790684db41571d04b5c5ed5952 Mon Sep 17 00:00:00 2001 From: David Rees Date: Mon, 23 Dec 2024 12:04:21 -0800 Subject: [PATCH] pw_bluetooth_proxy: Add missing fields to l2cap coc move MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also group mutex protected fields together to make it easier to compare for future move changes. Change-Id: If90bdf274de6a17fe1168540036422f59babdf92 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/256094 Docs-Not-Needed: Ben Lawson Commit-Queue: Auto-Submit Lint: Lint 🤖 Docs-Not-Needed: David Rees Reviewed-by: Ben Lawson Pigweed-Auto-Submit: David Rees Presubmit-Verified: CQ Bot Account Commit-Queue: David Rees --- pw_bluetooth_proxy/l2cap_coc.cc | 8 +++++--- pw_bluetooth_proxy/public/pw_bluetooth_proxy/l2cap_coc.h | 8 ++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pw_bluetooth_proxy/l2cap_coc.cc b/pw_bluetooth_proxy/l2cap_coc.cc index 6197ee36d..df6c0b82f 100644 --- a/pw_bluetooth_proxy/l2cap_coc.cc +++ b/pw_bluetooth_proxy/l2cap_coc.cc @@ -44,6 +44,9 @@ L2capCoc::L2capCoc(L2capCoc&& other) std::lock_guard other_lock(other.mutex_); tx_credits_ = other.tx_credits_; remaining_sdu_bytes_to_ignore_ = other.remaining_sdu_bytes_to_ignore_; + rx_sdu_ = std::move(other.rx_sdu_); + rx_sdu_offset_ = other.rx_sdu_offset_; + rx_sdu_bytes_remaining_ = other.rx_sdu_bytes_remaining_; } pw::Status L2capCoc::Write(pw::span payload) { @@ -374,10 +377,9 @@ L2capCoc::L2capCoc( rx_mps_(rx_config.mps), tx_mtu_(tx_config.mtu), tx_mps_(tx_config.mps), - tx_credits_(tx_config.credits), - remaining_sdu_bytes_to_ignore_(0), payload_from_controller_fn_(std::move(payload_from_controller_fn)), - receive_fn_multibuf_(std::move(receive_fn_multibuf)) {} + receive_fn_multibuf_(std::move(receive_fn_multibuf)), + tx_credits_(tx_config.credits) {} std::optional L2capCoc::DequeuePacket() { if (state() != State::kRunning) { diff --git a/pw_bluetooth_proxy/public/pw_bluetooth_proxy/l2cap_coc.h b/pw_bluetooth_proxy/public/pw_bluetooth_proxy/l2cap_coc.h index eced25553..6ade1ebb6 100644 --- a/pw_bluetooth_proxy/public/pw_bluetooth_proxy/l2cap_coc.h +++ b/pw_bluetooth_proxy/public/pw_bluetooth_proxy/l2cap_coc.h @@ -161,16 +161,16 @@ class L2capCoc : public L2capChannel { multibuf::MultiBufAllocator& rx_multibuf_allocator_; L2capSignalingChannel* signaling_channel_; - sync::Mutex mutex_; uint16_t rx_mtu_; uint16_t rx_mps_; uint16_t tx_mtu_; uint16_t tx_mps_; - uint16_t tx_credits_ PW_GUARDED_BY(mutex_); - uint16_t remaining_sdu_bytes_to_ignore_ PW_GUARDED_BY(mutex_); Function payload)> payload_from_controller_fn_; - Function receive_fn_multibuf_; + + sync::Mutex mutex_; + uint16_t tx_credits_ PW_GUARDED_BY(mutex_); + uint16_t remaining_sdu_bytes_to_ignore_ PW_GUARDED_BY(mutex_) = 0; std::optional rx_sdu_ PW_GUARDED_BY(mutex_); uint16_t rx_sdu_offset_ PW_GUARDED_BY(mutex_) = 0; uint16_t rx_sdu_bytes_remaining_ PW_GUARDED_BY(mutex_) = 0;