Change in ...osmo-trx[master]: Transceiver: exit process when BTS drops connection

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/.

laforge gerrit-no-reply at lists.osmocom.org
Tue Aug 27 12:10:59 UTC 2019


laforge has submitted this change and it was merged. ( https://gerrit.osmocom.org/c/osmo-trx/+/15289 )

Change subject: Transceiver: exit process when BTS drops connection
......................................................................

Transceiver: exit process when BTS drops connection

We don't want to keep osmo-trx running in a started state once the BTS
controlling it becomes unavailable. If a socket towards the BTS fails,
it means the BTS is gone and the best thing to do is to stop the process
(alternatively we could go back to stopped state instead, and wait for
BTS to re-connect, fur so far this action is good enough).

Related: OS#4170
Change-Id: I2ccbe3c17b39fb792ea7810f840235c348054d66
---
M Transceiver52M/Transceiver.cpp
M Transceiver52M/Transceiver.h
2 files changed, 54 insertions(+), 31 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/Transceiver52M/Transceiver.cpp b/Transceiver52M/Transceiver.cpp
index 9a1c446..23aabdd 100644
--- a/Transceiver52M/Transceiver.cpp
+++ b/Transceiver52M/Transceiver.cpp
@@ -750,7 +750,7 @@
   return true;
 }
 
-void Transceiver::driveControl(size_t chan)
+bool Transceiver::driveControl(size_t chan)
 {
   char buffer[MAX_PACKET_LENGTH + 1];
   char response[MAX_PACKET_LENGTH + 1];
@@ -761,7 +761,7 @@
   msgLen = read(mCtrlSockets[chan], buffer, MAX_PACKET_LENGTH);
   if (msgLen <= 0) {
     LOGCHAN(chan, DTRXCTRL, WARNING) << "mCtrlSockets read(" << mCtrlSockets[chan] << ") failed: " << msgLen;
-    return;
+    return false;
   }
 
   /* Zero-terminate received string */
@@ -770,7 +770,7 @@
   /* Verify a command signature */
   if (strncmp(buffer, "CMD ", 4)) {
     LOGC(DTRXCTRL, WARNING) << "bogus message on control interface";
-    return;
+    return false;
   }
 
   /* Set command pointer */
@@ -889,7 +889,7 @@
     if ((timeslot < 0) || (timeslot > 7)) {
       LOGC(DTRXCTRL, WARNING) << "bogus message on control interface";
       sprintf(response,"RSP SETSLOT 1 %d %d",timeslot,corrCode);
-      return;
+      return true;
     }
     mStates[chan].chanType[timeslot] = (ChannelCombination) corrCode;
     setModulus(timeslot, chan);
@@ -922,8 +922,11 @@
 
   LOGCHAN(chan, DTRXCTRL, INFO) << "response is '" << response << "'";
   msgLen = write(mCtrlSockets[chan], response, strlen(response) + 1);
-  if (msgLen <= 0)
+  if (msgLen <= 0) {
     LOGCHAN(chan, DTRXCTRL, WARNING) << "mCtrlSockets write(" << mCtrlSockets[chan] << ") failed: " << msgLen;
+    return false;
+  }
+  return true;
 }
 
 bool Transceiver::driveTxPriorityQueue(size_t chan)
@@ -990,18 +993,21 @@
   return true;
 }
 
-void Transceiver::driveReceiveRadio()
+bool Transceiver::driveReceiveRadio()
 {
   int rc = mRadioInterface->driveReceiveRadio();
   if (rc == 0) {
     usleep(100000);
-  } else if (rc < 0) {
-    LOG(FATAL) << "radio Interface receive failed, requesting stop.";
-    osmo_signal_dispatch(SS_MAIN, S_MAIN_STOP_REQUIRED, NULL);
-  } else if (mForceClockInterface || mTransmitDeadlineClock > mLastClockUpdateTime + GSM::Time(216,0)) {
-    mForceClockInterface = false;
-    writeClockInterface();
+    return true;
   }
+  if (rc < 0)
+    return false;
+
+  if (mForceClockInterface || mTransmitDeadlineClock > mLastClockUpdateTime + GSM::Time(216,0)) {
+    mForceClockInterface = false;
+    return writeClockInterface();
+  }
+  return true;
 }
 
 void Transceiver::logRxBurst(size_t chan, const struct trx_ul_burst_ind *bi)
@@ -1026,22 +1032,21 @@
     << " bits: "   << os;
 }
 
-void Transceiver::driveReceiveFIFO(size_t chan)
+bool Transceiver::driveReceiveFIFO(size_t chan)
 {
   struct trx_ul_burst_ind bi;
 
   if (!pullRadioVector(chan, &bi))
-        return;
+    return false;
+
   if (!bi.idle)
-       logRxBurst(chan, &bi);
+    logRxBurst(chan, &bi);
 
   switch (mVersionTRXD[chan]) {
     case 0:
-      trxd_send_burst_ind_v0(chan, mDataSockets[chan], &bi);
-      break;
+      return trxd_send_burst_ind_v0(chan, mDataSockets[chan], &bi);
     case 1:
-      trxd_send_burst_ind_v1(chan, mDataSockets[chan], &bi);
-      break;
+      return trxd_send_burst_ind_v1(chan, mDataSockets[chan], &bi);
     default:
       OSMO_ASSERT(false);
   }
@@ -1102,7 +1107,7 @@
 
 
 
-void Transceiver::writeClockInterface()
+bool Transceiver::writeClockInterface()
 {
   int msgLen;
   char command[50];
@@ -1112,11 +1117,13 @@
   LOG(INFO) << "ClockInterface: sending " << command;
 
   msgLen = write(mClockSocket, command, strlen(command) + 1);
-  if (msgLen <= 0)
-    LOG(WARNING) << "mClockSocket write(" << mClockSocket << ") failed: " << msgLen;
+  if (msgLen <= 0) {
+    LOG(ERROR) << "mClockSocket write(" << mClockSocket << ") failed: " << msgLen;
+    return false;
+  }
 
   mLastClockUpdateTime = mTransmitDeadlineClock;
-
+  return true;
 }
 
 void *RxUpperLoopAdapter(TrxChanThParams *params)
@@ -1131,7 +1138,11 @@
   set_selfthread_name(thread_name);
 
   while (1) {
-    trx->driveReceiveFIFO(num);
+    if (!trx->driveReceiveFIFO(num)) {
+      LOGCHAN(num, DMAIN, FATAL) << "Something went wrong in thread " << thread_name << ", requesting stop";
+      osmo_signal_dispatch(SS_MAIN, S_MAIN_STOP_REQUIRED, NULL);
+      break;
+    }
     pthread_testcancel();
   }
   return NULL;
@@ -1142,7 +1153,11 @@
   set_selfthread_name("RxLower");
 
   while (1) {
-    transceiver->driveReceiveRadio();
+    if (!transceiver->driveReceiveRadio()) {
+      LOG(FATAL) << "Something went wrong in thread RxLower, requesting stop";
+      osmo_signal_dispatch(SS_MAIN, S_MAIN_STOP_REQUIRED, NULL);
+      break;
+    }
     pthread_testcancel();
   }
   return NULL;
@@ -1171,7 +1186,11 @@
   set_selfthread_name(thread_name);
 
   while (1) {
-    trx->driveControl(num);
+    if (!trx->driveControl(num)) {
+      LOGCHAN(num, DTRXCTRL, FATAL) << "Something went wrong in thread " << thread_name << ", requesting stop";
+      osmo_signal_dispatch(SS_MAIN, S_MAIN_STOP_REQUIRED, NULL);
+      break;
+    }
     pthread_testcancel();
   }
   return NULL;
@@ -1189,7 +1208,11 @@
   set_selfthread_name(thread_name);
 
   while (1) {
-    trx->driveTxPriorityQueue(num);
+    if (!trx->driveTxPriorityQueue(num)) {
+      LOGCHAN(num, DMAIN, FATAL) << "Something went wrong in thread " << thread_name << ", requesting stop";
+      osmo_signal_dispatch(SS_MAIN, S_MAIN_STOP_REQUIRED, NULL);
+      break;
+    }
     pthread_testcancel();
   }
   return NULL;
diff --git a/Transceiver52M/Transceiver.h b/Transceiver52M/Transceiver.h
index 1a4d28f..0d09854 100644
--- a/Transceiver52M/Transceiver.h
+++ b/Transceiver52M/Transceiver.h
@@ -191,7 +191,7 @@
   CorrType expectedCorrType(GSM::Time currTime, size_t chan);
 
   /** send messages over the clock socket */
-  void writeClockInterface(void);
+  bool writeClockInterface(void);
 
   int mSPSTx;                          ///< number of samples per Tx symbol
   int mSPSRx;                          ///< number of samples per Rx symbol
@@ -221,16 +221,16 @@
 
 protected:
   /** drive lower receive I/O and burst generation */
-  void driveReceiveRadio();
+  bool driveReceiveRadio();
 
   /** drive demodulation of GSM bursts */
-  void driveReceiveFIFO(size_t chan);
+  bool driveReceiveFIFO(size_t chan);
 
   /** drive transmission of GSM bursts */
   void driveTxFIFO();
 
   /** drive handling of control messages from GSM core */
-  void driveControl(size_t chan);
+  bool driveControl(size_t chan);
 
   /**
     drive modulation and sorting of GSM bursts from GSM core

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-trx/+/15289
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Change-Id: I2ccbe3c17b39fb792ea7810f840235c348054d66
Gerrit-Change-Number: 15289
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: laforge <laforge at gnumonks.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190827/c7408c49/attachment.htm>


More information about the gerrit-log mailing list