<div dir="ltr"><span name="Holger Hans Peter Freyther" class="">Hi <span style="background:none repeat scroll 0% 0% yellow" class="">Holger</span>,</span><br><br>Sorry for slow response.<br>Actually I think that we should implement more intellectual <span id="result_box" class="" lang="en"><span class="">behavior</span></span> of <span style="background:none repeat scroll 0% 0% yellow" class="">PCU</span> for handling restarts and disconnections of <span style="background:none repeat scroll 0% 0% yellow" class="">BTS</span> and <span style="background:none repeat scroll 0% 0% yellow" class="">SGSN</span>.<br>
I should try to find the way to solve this problem, but I will commit this patch, because it fixes current problems.<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/7/13 Holger Hans Peter Freyther <span dir="ltr"><<a href="mailto:holger@moiji-mobile.com" target="_blank">holger@moiji-mobile.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The PCU does not properly re-set the state when the connection to the<br>
BTS is lost (and the SGSN potentially is re-started during that). This<br>
results in the BSSGP BVCI > 1 remaining blocked and no data will be<br>
accepted by the SGSN.<br>
<br>
Add the '-e' option and exit the PCU when the BSSGP/NS are getting<br>
destroyed.<br>
---<br>
 src/gprs_bssgp_pcu.cpp | 13 ++++++++++++-<br>
 src/gprs_bssgp_pcu.h   |  3 ++-<br>
 src/openbts_sock.cpp   |  2 +-<br>
 src/pcu_l1_if.cpp      |  2 +-<br>
 src/pcu_main.cpp       |  7 ++++++-<br>
 src/sysmo_sock.cpp     |  2 +-<br>
 6 files changed, 23 insertions(+), 6 deletions(-)<br>
<br>
diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp<br>
index c791913..59185e3 100644<br>
--- a/src/gprs_bssgp_pcu.cpp<br>
+++ b/src/gprs_bssgp_pcu.cpp<br>
@@ -27,6 +27,7 @@ struct bssgp_bvc_ctx *bctx = NULL;<br>
 struct gprs_nsvc *nsvc = NULL;<br>
 static int bvc_sig_reset = 0, bvc_reset = 0, bvc_unblocked = 0;<br>
 extern uint16_t spoof_mcc, spoof_mnc;<br>
+static int exit_on_destroy = 0;<br>
<br>
 struct osmo_timer_list bvc_timer;<br>
<br>
@@ -640,8 +641,13 @@ int gprs_bssgp_create(uint16_t local_port, uint32_t sgsn_ip,<br>
        return 0;<br>
 }<br>
<br>
-void gprs_bssgp_destroy(void)<br>
+void gprs_bssgp_destroy_or_exit(void)<br>
 {<br>
+       if (exit_on_destroy) {<br>
+               LOGP(DBSSGP, LOGL_NOTICE, "Exiting on BSSGP destruction.\n");<br>
+               exit(0);<br>
+       }<br>
+<br>
        if (!bssgp_nsi)<br>
                return;<br>
<br>
@@ -662,3 +668,8 @@ void gprs_bssgp_destroy(void)<br>
        bssgp_nsi = NULL;<br>
 }<br>
<br>
+void gprs_bssgp_exit_on_destroy(void)<br>
+{<br>
+       LOGP(DBSSGP, LOGL_NOTICE, "Going to quit on BSSGP destruction\n");<br>
+       exit_on_destroy = 1;<br>
+}<br>
diff --git a/src/gprs_bssgp_pcu.h b/src/gprs_bssgp_pcu.h<br>
index d669c3a..dc57e4f 100644<br>
--- a/src/gprs_bssgp_pcu.h<br>
+++ b/src/gprs_bssgp_pcu.h<br>
@@ -56,6 +56,7 @@ int gprs_bssgp_create(uint16_t local_port, uint32_t sgsn_ip, uint16_t<br>
                uint16_t mcc, uint16_t mnc, uint16_t lac, uint16_t rac,<br>
                uint16_t cell_id);<br>
<br>
-void gprs_bssgp_destroy(void);<br>
+void gprs_bssgp_exit_on_destroy(void);<br>
+void gprs_bssgp_destroy_or_exit(void);<br>
<br>
 #endif // GPRS_BSSGP_PCU_H<br>
diff --git a/src/openbts_sock.cpp b/src/openbts_sock.cpp<br>
index 845aa77..a09f834 100644<br>
--- a/src/openbts_sock.cpp<br>
+++ b/src/openbts_sock.cpp<br>
@@ -179,7 +179,7 @@ int pcu_l1if_open()<br>
<br>
 void pcu_l1if_close(void)<br>
 {<br>
-       gprs_bssgp_destroy();<br>
+       gprs_bssgp_destroy_or_exit();<br>
<br>
        /* FIXME: cleanup l1if */<br>
        talloc_free(l1fh->fl1h);<br>
diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp<br>
index 923070f..037cf60 100644<br>
--- a/src/pcu_l1_if.cpp<br>
+++ b/src/pcu_l1_if.cpp<br>
@@ -369,7 +369,7 @@ bssgp_failed:<br>
                                                trx, ts);<br>
                        }<br>
                }<br>
-               gprs_bssgp_destroy();<br>
+               gprs_bssgp_destroy_or_exit();<br>
                return 0;<br>
        }<br>
        LOGP(DL1IF, LOGL_INFO, "BTS available\n");<br>
diff --git a/src/pcu_main.cpp b/src/pcu_main.cpp<br>
index 041831f6..754043f 100644<br>
--- a/src/pcu_main.cpp<br>
+++ b/src/pcu_main.cpp<br>
@@ -60,6 +60,7 @@ static void print_help()<br>
                        "provided by BTS\n"<br>
                "  -r   --realtime PRIO Use SCHED_RR with the specified "<br>
                        "priority\n"<br>
+               "  -e   --exit          Exit the application on disconnect\n"<br>
                );<br>
 }<br>
<br>
@@ -75,10 +76,11 @@ static void handle_options(int argc, char **argv)<br>
                        { "mnc", 1, 0, 'n' },<br>
                        { "version", 0, 0, 'V' },<br>
                        { "realtime", 1, 0, 'r' },<br>
+                       { "exit", 0, 0, 'e' },<br>
                        { 0, 0, 0, 0 }<br>
                };<br>
<br>
-               c = getopt_long(argc, argv, "hc:m:n:Vr:",<br>
+               c = getopt_long(argc, argv, "hc:m:n:Vr:e",<br>
                                long_options, &option_idx);<br>
                if (c == -1)<br>
                        break;<br>
@@ -105,6 +107,9 @@ static void handle_options(int argc, char **argv)<br>
                case 'r':<br>
                        rt_prio = atoi(optarg);<br>
                        break;<br>
+               case 'e':<br>
+                       gprs_bssgp_exit_on_destroy();<br>
+                       break;<br>
                default:<br>
                        fprintf(stderr, "Unknown option '%c'\n", c);<br>
                        exit(0);<br>
diff --git a/src/sysmo_sock.cpp b/src/sysmo_sock.cpp<br>
index d4fb5a6..e116e5a 100644<br>
--- a/src/sysmo_sock.cpp<br>
+++ b/src/sysmo_sock.cpp<br>
@@ -117,7 +117,7 @@ static void pcu_sock_close(struct pcu_sock_state *state, int lost)<br>
                }<br>
        }<br>
<br>
-       gprs_bssgp_destroy();<br>
+       gprs_bssgp_destroy_or_exit();<br>
<br>
        if (lost) {<br>
                state->timer.cb = pcu_sock_timeout;<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.8.3.2<br>
<br>
<br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br>Regards,<br>Ivan Kluchnikov.<br><a href="http://fairwaves.ru/" target="_blank">http://fairwaves.ru</a><br>

</div>