From 176a4d2f33865a5c0433f8679f5e68f209d7b874 Mon Sep 17 00:00:00 2001 From: Alexander Couzens Date: Tue, 18 Sep 2018 20:07:37 +0200 Subject: GTP: refactor the echo timer Move the check of the echo timer into an own function. The gtp echo timer must be re-check everytime the echo-timer has been modified or deactivated via vty. Fixes the TTCN3 SGSN_Tests.TC_attach_restart_ctr_echo Change-Id: Ia33471a9a9cfc3887facb665c82094b99932052a --- src/gprs/gprs_sgsn.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/gprs/gprs_sgsn.c') diff --git a/src/gprs/gprs_sgsn.c b/src/gprs/gprs_sgsn.c index dc0e7c075..efbae2205 100644 --- a/src/gprs/gprs_sgsn.c +++ b/src/gprs/gprs_sgsn.c @@ -489,6 +489,17 @@ void sgsn_pdp_ctx_free(struct sgsn_pdp_ctx *pdp) talloc_free(pdp); } +void sgsn_ggsn_ctx_check_echo_timer(struct sgsn_ggsn_ctx *ggc) +{ + if (llist_empty(&ggc->pdp_list) || ggc->echo_interval <= 0) { + if (osmo_timer_pending(&ggc->echo_timer)) + osmo_timer_del(&ggc->echo_timer); + } else { + if (!osmo_timer_pending(&ggc->echo_timer)) + osmo_timer_schedule(&ggc->echo_timer, ggc->echo_interval, 0); + } +} + /* GGSN contexts */ static void echo_timer_cb(void *data) { @@ -742,15 +753,14 @@ int sgsn_ggsn_ctx_drop_all_pdp_except(struct sgsn_ggsn_ctx *ggsn, struct sgsn_pd void sgsn_ggsn_ctx_add_pdp(struct sgsn_ggsn_ctx *ggc, struct sgsn_pdp_ctx *pdp) { - if (llist_empty(&ggc->pdp_list) && ggc->echo_interval > 0) - osmo_timer_schedule(&ggc->echo_timer, ggc->echo_interval, 0); + sgsn_ggsn_ctx_check_echo_timer(ggc); + llist_add(&pdp->ggsn_list, &ggc->pdp_list); } void sgsn_ggsn_ctx_remove_pdp(struct sgsn_ggsn_ctx *ggc, struct sgsn_pdp_ctx *pdp) { llist_del(&pdp->ggsn_list); - if (llist_empty(&ggc->pdp_list) && osmo_timer_pending(&ggc->echo_timer)) - osmo_timer_del(&ggc->echo_timer); + sgsn_ggsn_ctx_check_echo_timer(ggc); if (pdp->destroy_ggsn) sgsn_ggsn_ctx_free(pdp->ggsn); pdp->ggsn = NULL; -- cgit v1.2.3