tbf: Reduce m_new_tbf logging messages
Currently tbf->m_new_tbf may point to itself if no new TBF is
assigned. But this leads to additional logging messages, since the
code in set_new_tbf and tbf_free assumes, that a real new TBF is
assigned and generates log messages accordingly.
This commit adds checks to avoid those messages in the above case.
Sponsored-by: On-Waves ehf
diff --git a/src/tbf.cpp b/src/tbf.cpp
index 6f4f15c..388f82d 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -55,15 +55,16 @@
{
if (m_new_tbf) {
if (m_new_tbf == tbf) {
- LOGP(DRLCMAC, LOGL_NOTICE,
+ LOGP(DRLCMAC, LOGL_INFO,
"%s reassigning %s to m_new_tbf\n",
tbf_name(this), tbf_name(tbf));
return;
}
- LOGP(DRLCMAC, LOGL_NOTICE,
- "%s m_new_tbf is already assigned to %s, "
- "overwriting the old value with %s\n",
- tbf_name(this), tbf_name(m_new_tbf), tbf_name(tbf));
+ if (m_new_tbf != this)
+ LOGP(DRLCMAC, LOGL_NOTICE,
+ "%s m_new_tbf is already assigned to %s, "
+ "overwriting the old value with %s\n",
+ tbf_name(this), tbf_name(m_new_tbf), tbf_name(tbf));
/* Detach from other TBF */
m_new_tbf->m_old_tbf = NULL;
}
@@ -154,25 +155,33 @@
tbf->bts->tbf_dl_freed();
if (tbf->m_old_tbf) {
- LOGP(DRLCMAC, LOGL_INFO, "%s Old TBF %s still exists, detaching\n",
- tbf_name(tbf), tbf_name(tbf->m_old_tbf));
- if (tbf->m_old_tbf->m_new_tbf == tbf)
+ if (tbf->m_old_tbf == tbf) {
+ /* points to itself, ignore */
+ } else if (tbf->m_old_tbf->m_new_tbf == tbf) {
+ LOGP(DRLCMAC, LOGL_INFO,
+ "%s Old TBF %s still exists, detaching\n",
+ tbf_name(tbf), tbf_name(tbf->m_old_tbf));
tbf->m_old_tbf->m_new_tbf = NULL;
- else
+ } else {
LOGP(DRLCMAC, LOGL_ERROR, "%s Software error: "
"tbf->m_old_tbf->m_new_tbf != tbf\n",
tbf_name(tbf));
+ }
}
if (tbf->m_new_tbf) {
- LOGP(DRLCMAC, LOGL_INFO, "%s New TBF %s still exists, detaching\n",
- tbf_name(tbf), tbf_name(tbf->m_new_tbf));
- if (tbf->m_new_tbf->m_old_tbf == tbf)
+ if (tbf->m_new_tbf == tbf) {
+ /* points to itself, ignore */
+ } else if (tbf->m_new_tbf->m_old_tbf == tbf) {
+ LOGP(DRLCMAC, LOGL_INFO,
+ "%s New TBF %s still exists, detaching\n",
+ tbf_name(tbf), tbf_name(tbf->m_new_tbf));
tbf->m_new_tbf->m_old_tbf = NULL;
- else
+ } else {
LOGP(DRLCMAC, LOGL_ERROR, "%s Software error: "
"tbf->m_new_tbf->m_old_tbf != tbf\n",
tbf_name(tbf));
+ }
}
LOGP(DRLCMAC, LOGL_DEBUG, "********** TBF ends here **********\n");