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

pespin gerrit-no-reply at lists.osmocom.org
Mon Aug 26 10:11:54 UTC 2019


pespin has uploaded this change for review. ( 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, 58 insertions(+), 33 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/89/15289/1

diff --git a/Transceiver52M/Transceiver.cpp b/Transceiver52M/Transceiver.cpp
index 8ba4674..239f309 100644
--- a/Transceiver52M/Transceiver.cpp
+++ b/Transceiver52M/Transceiver.cpp
@@ -708,7 +708,7 @@
 ret_idle:
   bi->idle = true;
   delete radio_burst;
-  return false;
+  return true;
 }
 
 void Transceiver::reset()
@@ -749,7 +749,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];
@@ -760,7 +760,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 */
@@ -769,7 +769,7 @@
   /* Verify a command signature */
   if (strncmp(buffer, "CMD ", 4)) {
     LOGC(DTRXCTRL, WARNING) << "bogus message on control interface";
-    return;
+    return false;
   }
 
   /* Set command pointer */
@@ -888,7 +888,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);
@@ -921,8 +921,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)
@@ -989,18 +992,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)
@@ -1025,22 +1031,23 @@
     << " 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;
-  if (!bi.idle)
-       logRxBurst(chan, &bi);
+    return false;
+
+  if (bi.idle)
+    return true;
+
+  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);
   }
@@ -1101,7 +1108,7 @@
 
 
 
-void Transceiver::writeClockInterface()
+bool Transceiver::writeClockInterface()
 {
   int msgLen;
   char command[50];
@@ -1111,11 +1118,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)
@@ -1130,7 +1139,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;
@@ -1141,7 +1154,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;
@@ -1170,7 +1187,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;
@@ -1188,7 +1209,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: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190826/e225d18e/attachment.htm>


More information about the gerrit-log mailing list