aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
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')
-rw-r--r--src/gprs_ms.cpp8
-rw-r--r--src/gprs_ms.h2
2 files changed, 10 insertions, 0 deletions
diff --git a/src/gprs_ms.cpp b/src/gprs_ms.cpp
index 318ebec2..b36c61db 100644
--- a/src/gprs_ms.cpp
+++ b/src/gprs_ms.cpp
@@ -62,6 +62,14 @@ GprsMs::Guard::~Guard()
m_ms->unref();
}
+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 840a2295..1a135cbb 100644
--- a/src/gprs_ms.h
+++ b/src/gprs_ms.h
@@ -51,6 +51,8 @@ public:
Guard(GprsMs *ms);
~Guard();
+ bool is_idle() const;
+
private:
GprsMs * const m_ms;
};