aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2022-04-28 14:47:51 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2022-04-28 16:04:04 +0200
commit4821c9f4dff3cb9d06ee8392de18fd7c63399bf0 (patch)
tree0ff48cae3c8a185006f3622e2caf648ac5a5e30b
parente731301c2586921dd1a689f5a33e44fce82e0258 (diff)
paging: Recalculate work timer if waiting for retrans
If the queue is only holding requests in retransmition state, when we add a new one, we have to re-calculate the work timer to a lower value instead of letting it wait for the first retransmit to be ready. Change-Id: Ibd4f8921c92f7481f0b9943041c141640ab812c8
-rw-r--r--src/osmo-bsc/paging.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/osmo-bsc/paging.c b/src/osmo-bsc/paging.c
index fcb038bbb..1430c225b 100644
--- a/src/osmo-bsc/paging.c
+++ b/src/osmo-bsc/paging.c
@@ -432,7 +432,28 @@ static int _paging_request(const struct bsc_paging_params *params, struct gsm_bt
t3113_timeout_s = calculate_timer_3113(req, reqs_before_same_pgroup);
osmo_timer_schedule(&req->T3113, t3113_timeout_s, 0);
- paging_schedule_if_needed(bts_entry);
+
+ /* Trigger scheduler if needed: */
+ if (!osmo_timer_pending(&bts_entry->work_timer)) {
+ paging_handle_pending_requests(bts_entry);
+ } else if (last_initial_req == NULL) {
+ /* Worker timer is armed -> there was already one req before
+ * last_initial_req is NULL -> There were no initial requests in
+ * the list, aka the timer is waiting for retransmition,
+ * which is a longer period.
+ * Let's recaculate the time to adapt it to initial_period: */
+ struct timespec now, elapsed, tdiff;
+ osmo_clock_gettime(CLOCK_MONOTONIC, &now);
+ /* This is what used to be the first req (retrans state) in the queue: */
+ req = llist_entry(req->entry.next, struct gsm_paging_request, entry);
+ timespecsub(&now, &req->last_attempt_ts, &elapsed);
+ if (timespeccmp(&elapsed, &initial_period, <)) {
+ timespecsub(&initial_period, &elapsed, &tdiff);
+ } else {
+ tdiff = (struct timespec){.tv_sec = 0, .tv_nsec = 0 };
+ }
+ osmo_timer_schedule(&bts_entry->work_timer, tdiff.tv_sec, tdiff.tv_nsec / 1000);
+ } /* else: worker is already ongoing submitting initial requests, nothing do be done */
return 0;
}