From 81fb892700c6e55c2b806f73d1aa8dc658ba14ef Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 13 Jul 2016 15:43:20 -0700 Subject: [PATCH] Preserve packet+burst boundaries Do not allow the server readStream() endpoint to mix a second readStream() into the buffer when the flags indicate that the last read was an end of burst or single packet mode. --- Changelog.txt | 5 +++++ server/ServerStreamData.cpp | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 4ae1be3..f2629bc 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,3 +1,8 @@ +Release 0.3.1 (pending) +========================== + +- Preserve packet+burst boundaries in server readStream() endpoint + Release 0.3.0 (2016-07-10) ========================== diff --git a/server/ServerStreamData.cpp b/server/ServerStreamData.cpp index 307c0cf..a44e600 100644 --- a/server/ServerStreamData.cpp +++ b/server/ServerStreamData.cpp @@ -1,4 +1,5 @@ // Copyright (c) 2015-2015 Josh Blum +// Copyright (c) 2016-2016 Bastille Networks // SPDX-License-Identifier: BSL-1.0 #include "ServerStreamData.hpp" @@ -162,6 +163,7 @@ void ServerStreamData::sendEndpointWork(void) size_t elemsRead = 0; while (not done) { + flags = 0; //flags is an in/out parameter and must be cleared for consistency const size_t numElems = std::min(mtuElems, elemsLeft); ret = device->readStream(stream, buffs.data(), numElems, flags, timeNs, SOAPY_REMOTE_SOCKET_TIMEOUT_US); if (ret == SOAPY_SDR_TIMEOUT) continue; @@ -179,7 +181,8 @@ void ServerStreamData::sendEndpointWork(void) //fill remaining buffer with no timeout //This is a latency optimization to forward to the host ASAP, //but to use the full bandwidth when more data is available. - if (elemsRead != 0 and elemsLeft != 0) + //Do not allow this optimization when end of burst or single packet mode to preserve boundaries + if (elemsRead != 0 and elemsLeft != 0 and (flags & (SOAPY_SDR_END_BURST | SOAPY_SDR_ONE_PACKET)) == 0) { int flags1 = 0; long long timeNs1 = 0;