llc: Use timeradd and timercmp and fix for < 1s PDU llc timeouts
This commit is contained in:
parent
985fd114f2
commit
51e093bd1c
13
src/llc.cpp
13
src/llc.cpp
|
@ -91,11 +91,10 @@ void gprs_llc::calc_pdu_lifetime(BTS *bts, const uint16_t pdu_delay_csec, struct
|
|||
}
|
||||
|
||||
/* calculate timestamp of timeout */
|
||||
gettimeofday(tv, NULL);
|
||||
tv->tv_usec += (delay_csec % 100) * 10000;
|
||||
tv->tv_sec += delay_csec / 100;
|
||||
if (tv->tv_usec > 999999) {
|
||||
tv->tv_usec -= 1000000;
|
||||
tv->tv_sec++;
|
||||
}
|
||||
struct timeval now, csec;
|
||||
gettimeofday(&now, NULL);
|
||||
csec.tv_usec = (delay_csec % 100) * 10000;
|
||||
csec.tv_sec = delay_csec / 100;
|
||||
|
||||
timeradd(&now, &csec, tv);
|
||||
}
|
||||
|
|
|
@ -687,10 +687,11 @@ struct msgb *gprs_rlcmac_tbf::llc_dequeue(bssgp_bvc_ctx *bctx)
|
|||
while ((msg = m_llc.dequeue())) {
|
||||
tv = (struct timeval *)msg->data;
|
||||
msgb_pull(msg, sizeof(*tv));
|
||||
if (tv->tv_sec /* not infinite */
|
||||
&& (tv_now.tv_sec > tv->tv_sec /* and secs expired */
|
||||
|| (tv_now.tv_sec == tv->tv_sec /* .. or if secs equal .. */
|
||||
&& tv_now.tv_usec > tv->tv_usec))) { /* .. usecs expired */
|
||||
|
||||
/* Timeout is infinite */
|
||||
if (tv->tv_sec == 0 && tv->tv_usec == 0)
|
||||
break;
|
||||
if (timercmp(&tv_now, tv, >)) {
|
||||
LOGP(DRLCMACDL, LOGL_NOTICE, "%s Discarding LLC PDU "
|
||||
"because lifetime limit reached\n",
|
||||
tbf_name(this));
|
||||
|
|
Loading…
Reference in New Issue