[MERGED] osmo-trx[master]: transceiver: Fix POWEROFF crash on USRP2/N200/X300 devices

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Tom Tsou gerrit-no-reply at lists.osmocom.org
Fri Jun 16 17:04:26 UTC 2017


Tom Tsou has submitted this change and it was merged.

Change subject: transceiver: Fix POWEROFF crash on USRP2/N200/X300 devices
......................................................................


transceiver: Fix POWEROFF crash on USRP2/N200/X300 devices

Upon issuing POWEROFF command to a running transceiver, UHD
interfacing thread state may become undefined if the device
is stopped with I/O threads still active. Bad behavior is
device dependent with only network based USRP devices
affected. USB based device thread behavior stops and shutdowns
as expected. Tested with N200, X300, and B210.

Tested solutions include the following:

  1. Set pthread_setcanceltype() with PTHREAD_CANCEL_ASYNCHRONOUS
  2. Add sleep delay to allow I/O threads to timeout before
     stopping the device
  3. Wait for I/O threads to join after cancellation before stopping
     the device

This patch resolves the issue by with the third approach. Number 1
is not guaranteed to always work with UHD internals as driver code
may explicitly set thread parameters. Using sleep calls to fix
order-of-operation issues is almost never a good idea.

Change-Id: Ib72ab98a27a02084b040319046c92d1c4157ae4c
---
M Transceiver52M/Transceiver.cpp
1 file changed, 4 insertions(+), 5 deletions(-)

Approvals:
  Tom Tsou: Looks good to me, approved
  Max: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/Transceiver52M/Transceiver.cpp b/Transceiver52M/Transceiver.cpp
index 66eff7f..61da416 100644
--- a/Transceiver52M/Transceiver.cpp
+++ b/Transceiver52M/Transceiver.cpp
@@ -297,6 +297,10 @@
   LOG(NOTICE) << "Stopping the transceiver";
   mTxLowerLoopThread->cancel();
   mRxLowerLoopThread->cancel();
+  mTxLowerLoopThread->join();
+  mRxLowerLoopThread->join();
+  delete mTxLowerLoopThread;
+  delete mRxLowerLoopThread;
 
   for (size_t i = 0; i < mChans; i++) {
     mRxServiceLoopThreads[i]->cancel();
@@ -314,11 +318,6 @@
 
     mTxPriorityQueues[i].clear();
   }
-
-  mTxLowerLoopThread->join();
-  mRxLowerLoopThread->join();
-  delete mTxLowerLoopThread;
-  delete mRxLowerLoopThread;
 
   mOn = false;
   LOG(NOTICE) << "Transceiver stopped";

-- 
To view, visit https://gerrit.osmocom.org/2927
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib72ab98a27a02084b040319046c92d1c4157ae4c
Gerrit-PatchSet: 2
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Tom Tsou <tom at tsou.cc>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Tom Tsou <tom at tsou.cc>



More information about the gerrit-log mailing list