Change in osmo-trx[master]: lms: Make sure LMS_Close is called when Device is torn down

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

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Mon Dec 3 17:38:58 UTC 2018


Pau Espin Pedrol has uploaded this change for review. ( https://gerrit.osmocom.org/12086


Change subject: lms: Make sure LMS_Close is called when Device is torn down
......................................................................

lms: Make sure LMS_Close is called when Device is torn down

This change fixes lots of memory leaks inside libLimeSuite as
announced by ASan after exiting the osmo-trx process (throgh
CTRL+C for instance).

This way also we make sure libLimeSuite can communicate with the HW and
close whatever subsystems were enabled during LMS_Open time.

Change-Id: I56ffb87079e34aa2d0322fd2ca6429742f9f7640
---
M Transceiver52M/device/lms/LMSDevice.cpp
M Transceiver52M/device/lms/LMSDevice.h
2 files changed, 11 insertions(+), 0 deletions(-)



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

diff --git a/Transceiver52M/device/lms/LMSDevice.cpp b/Transceiver52M/device/lms/LMSDevice.cpp
index 2ceca0d..144f75d 100644
--- a/Transceiver52M/device/lms/LMSDevice.cpp
+++ b/Transceiver52M/device/lms/LMSDevice.cpp
@@ -57,6 +57,15 @@
 	m_last_tx_overruns.resize(chans, 0);
 }
 
+LMSDevice::~LMSDevice()
+{
+	LOGC(DDEV, INFO) << "Closing LMS device";
+	if (m_lms_dev) {
+		LMS_Close(m_lms_dev);
+		m_lms_dev = NULL;
+	}
+}
+
 static void lms_log_callback(int lvl, const char *msg)
 {
 	/* map lime specific log levels */
@@ -204,6 +213,7 @@
 out_close:
 	LOGC(DDEV, ALERT) << "Error in LMS open, closing: " << LMS_GetLastErrorMessage();
 	LMS_Close(m_lms_dev);
+	m_lms_dev = NULL;
 	return -1;
 }
 
diff --git a/Transceiver52M/device/lms/LMSDevice.h b/Transceiver52M/device/lms/LMSDevice.h
index 6635c13..d1a8813 100644
--- a/Transceiver52M/device/lms/LMSDevice.h
+++ b/Transceiver52M/device/lms/LMSDevice.h
@@ -74,6 +74,7 @@
 	LMSDevice(size_t tx_sps, size_t rx_sps, InterfaceType iface, size_t chans, double lo_offset,
 		  const std::vector<std::string>& tx_paths,
 		  const std::vector<std::string>& rx_paths);
+	~LMSDevice();
 
 	/** Instantiate the LMS */
 	int open(const std::string &args, int ref, bool swap_channels);

-- 
To view, visit https://gerrit.osmocom.org/12086
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I56ffb87079e34aa2d0322fd2ca6429742f9f7640
Gerrit-Change-Number: 12086
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181203/b4572fc8/attachment.htm>


More information about the gerrit-log mailing list