Ad hoc relay: Iterate the PTP block queue instead of indexing it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-11-03 22:03:18 +01:00
1 parent c1c815da80
commit 92fbf32e19
1 file changed
+7 -3
+7 -3
View File
@@ -376,10 +376,14 @@ static int fillRelayPtpQueue(AdhocSocket *sock) {
static size_t relayPtpReadable(const RelayPtpQueue &queue) {
u64 now = CoreTiming::GetGlobalTimeUsScaled();
size_t bytes = 0;
for (size_t i = 0; i < queue.blocks.size() && queue.blocks[i].readableAt <= now; ++i) {
bytes += queue.blocks[i].data.size() - (i == 0 ? queue.offset : 0);
for (const RelayPtpBlock &block : queue.blocks) {
if (block.readableAt > now) {
break;
}
bytes += block.data.size();
}
return bytes;
// Less what's already been read from the first one.
return bytes == 0 ? 0 : bytes - queue.offset;
}
static int ptp_recv_postoffice(int idx, void *data, int *len) {