From e503c988d825e0eaf5f56ed8dd68b318b3e43c04 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Fri, 13 Sep 2019 18:56:08 +0200 Subject: radioInterface: Atomically fetch and change underrun variable Otherwise, it could happen that underrun events are lost: TxLower (isUnderrun): RxLower (pullBuffer): read(underrun) read(underrun) write(underrun, |val) [maybe underrun becomes TRUE] write(underrun, false) Similary, it could happen the other direction if atomic was only applied to isUnderrun: TxLower (isUnderrun): RxLower (pullBuffer): read(underrun) -> true read(underrun)-> true write(underrun, false) write(underrun, true|val) where val=false So in here isUnderrun would return true twice while it should only return one. Change-Id: I684e0a5d2a9583a161d5a6593559b3a9e7cd57e3 --- Transceiver52M/radioInterfaceResamp.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Transceiver52M/radioInterfaceResamp.cpp') diff --git a/Transceiver52M/radioInterfaceResamp.cpp b/Transceiver52M/radioInterfaceResamp.cpp index 864cdee..b92432f 100644 --- a/Transceiver52M/radioInterfaceResamp.cpp +++ b/Transceiver52M/radioInterfaceResamp.cpp @@ -184,7 +184,7 @@ int RadioInterfaceResamp::pullBuffer() convert_short_float((float *) outerRecvBuffer->begin(), convertRecvBuffer[0], 2 * resamp_outchunk); - underrun |= local_underrun; + osmo_trx_sync_or_and_fetch(&underrun, local_underrun); readTimestamp += (TIMESTAMP) resamp_outchunk; /* Write to the end of the inner receive buffer */ @@ -232,7 +232,7 @@ bool RadioInterfaceResamp::pushBuffer() LOG(ALERT) << "Transmit error " << numSent; } - underrun |= local_underrun; + osmo_trx_sync_or_and_fetch(&underrun, local_underrun); writeTimestamp += resamp_outchunk; return true; -- cgit v1.2.3