tbf_dl: Fix m_last_dl_drained_fn not set under some conditions
Old commit getting rid of LLC UI dummy and updating create_new_bsn()
function introduced a bug by not moving update of value m_last_dl_drained_fn
prior to a new break introduced.
As a result, the value is not updated in the case LLC queue becomes
drained but last few bytes are drained at exactly that moment.
Furthermore, then the IDLE tbf timer (X2031, keep_open())) returns always
true since according to it the drain never happened.
The impact of the bug is basically delaying a bit more than expected the
time the TBF stays in IDLE state with the TBF release process yet
to be started.
Related: OS#4849
Fixes: 7d0f9a0ec383fcfca934731bd6979b6be6629c90
Change-Id: I7420aeffda3500bcdc990291e4a56511af433ff9
diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp
index 2896378..d963644 100644
--- a/src/tbf_dl.cpp
+++ b/src/tbf_dl.cpp
@@ -684,6 +684,10 @@
int payload_written = 0;
if (llc_frame_length(&m_llc) == 0) {
+ /* The data just drained, store the current fn */
+ if (m_last_dl_drained_fn < 0)
+ m_last_dl_drained_fn = fn;
+
/* It is not clear, when the next real data will
* arrive, so request a DL ack/nack now */
request_dl_ack();
@@ -715,10 +719,6 @@
* space-1 octets */
m_llc.put_dummy_frame(space - 1);
- /* The data just drained, store the current fn */
- if (m_last_dl_drained_fn < 0)
- m_last_dl_drained_fn = fn;
-
LOGPTBFDL(this, LOGL_DEBUG,
"Empty chunk, added LLC dummy command of size %d, drained_since=%d\n",
llc_frame_length(&m_llc), frames_since_last_drain(fn));