library: CBSP_Adapter: Improve robustness of rebind and reconnect

Change-Id: Ibafbc8496eeadd0ea1b97056ef3b8a92bc43e9f1
This commit is contained in:
Pau Espin 2020-09-15 18:32:59 +02:00 committed by pespin
parent 609f1d6c10
commit 28aa466dd9
1 changed files with 13 additions and 0 deletions

View File

@ -41,6 +41,10 @@ function f_connect(charstring remote_host, IPL4asp_Types.PortNumber remote_port,
runs on CBSP_Adapter_CT {
var IPL4asp_Types.Result res;
map(self:CBSP[idx], system:CBSP);
if (g_cbsp_conn_id[idx] != -1) {
CBSP_CodecPort_CtrlFunct.f_IPL4_close(CBSP[idx], g_cbsp_conn_id[idx], {tcp := {}});
g_cbsp_conn_id[idx] := -1;
}
res := CBSP_CodecPort_CtrlFunct.f_IPL4_connect(CBSP[idx], remote_host, remote_port,
local_host, local_port, 0, { tcp :={} });
if (not ispresent(res.connId)) {
@ -58,7 +62,16 @@ function f_bind(charstring local_host, IPL4asp_Types.PortNumber local_port, inte
runs on CBSP_Adapter_CT {
var IPL4asp_Types.Result res;
map(self:CBSP[idx], system:CBSP);
if (g_cbsp_conn_id[idx] != -1) {
CBSP_CodecPort_CtrlFunct.f_IPL4_close(CBSP[idx], g_cbsp_conn_id[idx], {tcp := {}});
g_cbsp_conn_id[idx] := -1;
}
res := CBSP_CodecPort_CtrlFunct.f_IPL4_listen(CBSP[idx], local_host, local_port, { tcp:={} });
if (not ispresent(res.connId)) {
setverdict(fail, "Could not bind to CBSP port, check your configuration ",
"{local ", local_host, ":", local_port, "}");
mtc.stop;
}
g_cbsp_conn_id[idx] := res.connId;
f_set_tcp_segmentation(idx);