Skip to content

Commit 205700c

Browse files
committed
fix: bound shared topic tx failure path
1 parent dab3d5b commit 205700c

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

SharedTopicClient.hpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,16 @@ class SharedTopicClient : public LibXR::Application {
133133
ASSERT(packet_size <= slot.buffer.size_);
134134
LibXR::Topic::PackData(info.topic_crc32, slot.buffer, timestamp, data);
135135

136-
ASSERT(ready_packets_->Put(ReadyPacket{slot_index, packet_size}) ==
137-
LibXR::ErrorCode::OK);
138-
TxService(in_isr);
136+
if (ready_packets_->Put(ReadyPacket{slot_index, packet_size}) !=
137+
LibXR::ErrorCode::OK) {
138+
ReturnFreeSlot(slot_index);
139+
return;
140+
}
141+
KickTx(in_isr);
139142
}
140143

144+
void KickTx(bool in_isr) { tx_callback_.Run(in_isr, LibXR::ErrorCode::OK); }
145+
141146
void TxService(bool in_isr) {
142147
ReadyPacket packet;
143148
if (ready_packets_->Get(packet) != LibXR::ErrorCode::OK) {
@@ -149,14 +154,17 @@ class SharedTopicClient : public LibXR::Application {
149154
LibXR::ConstRawData{slot.buffer.addr_, packet.packet_size}, tx_op_,
150155
in_isr);
151156
if (static_cast<int8_t>(write_status) < 0) {
152-
ASSERT(ready_packets_->Put(packet) == LibXR::ErrorCode::OK);
157+
ReturnFreeSlot(packet.slot_index);
153158
return;
154159
}
155160

156161
ReturnFreeSlot(packet.slot_index);
157162
}
158163

159-
void OnWriteDone(bool in_isr, LibXR::ErrorCode) {
164+
void OnWriteDone(bool in_isr, LibXR::ErrorCode status) {
165+
if (static_cast<int8_t>(status) < 0) {
166+
return;
167+
}
160168
TxService(in_isr);
161169
}
162170

0 commit comments

Comments
 (0)