pespin has uploaded this change for review. ( 
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, 32 insertions(+), 6 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks 
refs/changes/72/42472/1

diff --git a/library/GTPv1U_Emulation.ttcnpp b/library/GTPv1U_Emulation.ttcnpp
index 6146147..5ae847d 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("No Space in PID Table for ", pid);
+}
 #endif


@@ -209,6 +233,8 @@
        g_c_seq_nr := f_rnd_int(65535);
        g_gtp1u_cfg := cfg;

+       f_pid_tbl_init();
+
        if (g_gtp1u_cfg.use_gtpu_daemon) {
 #ifdef GTP1U_EMULATION_HAVE_UECUPS
                map(self:UECUPS, system:UECUPS);
@@ -241,8 +267,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 */

--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/42472?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I7be2639761726c09e4ea6f75c57d8414c5dbf128
Gerrit-Change-Number: 42472
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <[email protected]>

Reply via email to