diff options
-rw-r--r-- | include/osmocom/sgsn/gprs_sgsn.h | 1 | ||||
-rw-r--r-- | src/gprs/gprs_sgsn.c | 18 | ||||
-rw-r--r-- | src/gprs/sgsn_vty.c | 2 |
3 files changed, 17 insertions, 4 deletions
diff --git a/include/osmocom/sgsn/gprs_sgsn.h b/include/osmocom/sgsn/gprs_sgsn.h index 2fbc0b6ab..1913591d2 100644 --- a/include/osmocom/sgsn/gprs_sgsn.h +++ b/include/osmocom/sgsn/gprs_sgsn.h @@ -375,6 +375,7 @@ void sgsn_ggsn_ctx_drop_pdp(struct sgsn_pdp_ctx *pctx); int sgsn_ggsn_ctx_drop_all_pdp_except(struct sgsn_ggsn_ctx *ggsn, struct sgsn_pdp_ctx *except); void sgsn_ggsn_ctx_add_pdp(struct sgsn_ggsn_ctx *ggc, struct sgsn_pdp_ctx *pdp); void sgsn_ggsn_ctx_remove_pdp(struct sgsn_ggsn_ctx *ggc, struct sgsn_pdp_ctx *pdp); +void sgsn_ggsn_ctx_check_echo_timer(struct sgsn_ggsn_ctx *ggc); struct apn_ctx { struct llist_head list; 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; diff --git a/src/gprs/sgsn_vty.c b/src/gprs/sgsn_vty.c index de193f03a..63985bcd9 100644 --- a/src/gprs/sgsn_vty.c +++ b/src/gprs/sgsn_vty.c @@ -383,6 +383,7 @@ DEFUN(cfg_ggsn_echo_interval, cfg_ggsn_echo_interval_cmd, "not be lower than 60 seconds, use this value for " \ "testing purposes only!%s", VTY_NEWLINE); + sgsn_ggsn_ctx_check_echo_timer(ggc); return CMD_SUCCESS; } @@ -395,6 +396,7 @@ DEFUN(cfg_ggsn_no_echo_interval, cfg_ggsn_no_echo_interval_cmd, struct sgsn_ggsn_ctx *ggc = sgsn_ggsn_ctx_find_alloc(id); ggc->echo_interval = -1; + sgsn_ggsn_ctx_check_echo_timer(ggc); return CMD_SUCCESS; } |