path: root/src
diff options
authorJacob Erlbeck <jerlbeck@sysmocom.de>2015-07-13 14:23:32 +0200
committerJacob Erlbeck <jerlbeck@sysmocom.de>2015-07-16 10:25:14 +0200
commitb2439bbb8a73f00873efd7f744f70be535496e90 (patch)
tree2df74c85923cca30c8d699925fb914ae85f765fc /src
parent3a10dbd56428cf0e79b738f62748509bbd04aa68 (diff)
ms: Add is_idle() method to GprsMs::Guard
Currently there is no simple way to determine, whether the MS object protected by a guard will continue to exist after the guard object is destroyed. This patch adds a is_idle() method that will return true if the MS object is just kept by the guard from being idle. In that case, the MS object would either be deleted or return true for GprsMs::is_idle() after the guard's destruction, provided that no TBF attachment took place in between. Sponsored-by: On-Waves ehf
Diffstat (limited to 'src')
2 files changed, 10 insertions, 0 deletions
diff --git a/src/gprs_ms.cpp b/src/gprs_ms.cpp
index 318ebec..b36c61d 100644
--- a/src/gprs_ms.cpp
+++ b/src/gprs_ms.cpp
@@ -62,6 +62,14 @@ GprsMs::Guard::~Guard()
+bool GprsMs::Guard::is_idle() const
+ if (!m_ms)
+ return true;
+ return !m_ms->m_ul_tbf && !m_ms->m_dl_tbf && m_ms->m_ref == 1;
void GprsMs::timeout(void *priv_)
GprsMs *ms = static_cast<GprsMs *>(priv_);
diff --git a/src/gprs_ms.h b/src/gprs_ms.h
index 840a229..1a135cb 100644
--- a/src/gprs_ms.h
+++ b/src/gprs_ms.h
@@ -51,6 +51,8 @@ public:
Guard(GprsMs *ms);
+ bool is_idle() const;
GprsMs * const m_ms;