pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/42472?usp=email )
Change subject: GTPv1U_Emulation: Clear entries from PidTable upon rx CUPS program_term_ind ......................................................................
GTPv1U_Emulation: Clear entries from PidTable upon rx CUPS program_term_ind
Otherwise it will evnetually run out of entries if enough commands are called sequentially.
Change-Id: I7be2639761726c09e4ea6f75c57d8414c5dbf128 --- M library/GTPv1U_Emulation.ttcnpp 1 file changed, 31 insertions(+), 6 deletions(-)
Approvals: Jenkins Builder: Verified osmith: Looks good to me, approved
diff --git a/library/GTPv1U_Emulation.ttcnpp b/library/GTPv1U_Emulation.ttcnpp index 6146147..7b1db12 100644 --- a/library/GTPv1U_Emulation.ttcnpp +++ b/library/GTPv1U_Emulation.ttcnpp @@ -82,9 +82,9 @@ /* pid <-> ConnHdlr mapping (for UECUPS process termination indication) */ type record PidTableRec { /* process ID of the running process */ - integer pid, + integer pid optional, /* component that started it */ - GTP1U_ConnHdlr vc_conn + GTP1U_ConnHdlr vc_conn optional }; #endif
@@ -113,8 +113,7 @@ private function f_comp_by_pid(integer pid) runs on GTPv1U_Emulation_CT return GTP1U_ConnHdlr { var integer i; for (i := 0; i < sizeof(PidTable); i := i+1) { - if (isbound(PidTable[i].pid) and PidTable[i].pid == pid) { - /* fixme: remove */ + if (ispresent(PidTable[i].pid) and PidTable[i].pid == pid) { return PidTable[i].vc_conn; } } @@ -136,10 +135,24 @@ }
#ifdef GTP1U_EMULATION_HAVE_UECUPS +private function f_pid_clear(integer idx) runs on GTPv1U_Emulation_CT { + PidTable[idx].pid := omit; + PidTable[idx].vc_conn := omit; +} + +private function f_pid_tbl_init() runs on GTPv1U_Emulation_CT { + var integer i; + + /* Initialize the ConnectionTable */ + for (i := 0; i < sizeof(PidTable); i := i+1) { + f_pid_clear(i); + } +} + private function f_pid_tbl_add(integer pid, GTP1U_ConnHdlr vc_conn) runs on GTPv1U_Emulation_CT { var integer i; for (i := 0; i < sizeof(PidTable); i := i+1) { - if (not isbound(PidTable[i].pid)) { + if (not ispresent(PidTable[i].pid)) { PidTable[i].pid := pid; PidTable[i].vc_conn := vc_conn; return; @@ -147,6 +160,17 @@ } testcase.stop("No Space in PID Table for ", pid); } + +private function f_pid_tbl_del(integer pid) runs on GTPv1U_Emulation_CT { + var integer i; + for (i := 0; i < sizeof(PidTable); i := i+1) { + if (ispresent(PidTable[i].pid) and PidTable[i].pid == pid) { + f_pid_clear(i); + return; + } + } + testcase.stop("Cannot find PID ", pid, " in PidTable for deletion"); +} #endif
@@ -211,6 +235,7 @@
if (g_gtp1u_cfg.use_gtpu_daemon) { #ifdef GTP1U_EMULATION_HAVE_UECUPS + f_pid_tbl_init(); map(self:UECUPS, system:UECUPS); res := UECUPS_CodecPort_CtrlFunct.f_IPL4_connect(UECUPS, mp_uecups_host, mp_uecups_port, "", -1, -1, { sctp := valueof(ts_SctpTuple) }); @@ -241,8 +266,8 @@ /* handle incoming program_term_ind; dispatch to whatever component started the process */ [] UECUPS.receive(tr_UECUPS_RecvFrom_R({program_term_ind:=?})) -> value rx { vc_conn := f_comp_by_pid(rx.msg.program_term_ind.pid); + f_pid_tbl_del(rx.msg.program_term_ind.pid); CLIENT.send(rx.msg.program_term_ind) to vc_conn; - /* FIXME: remove from table */ repeat; } /* handle incoming ipv6_slaac_ind; dispatch to whatever component started the process */