dexter has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmo-abis/+/32402 )

 (

5 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted 
one.
 )Change subject: e1d: fix logic to detect if a timeslot is in use
......................................................................

e1d: fix logic to detect if a timeslot is in use

When we check bfd->fd, we also treat 0 as "not in use". This is not
correct since 0 is a valid file descriptor (STDIN). Since we reliably
initialize the file descriptor numbers to -1 on startup we can fix this.
So let's treat all positive file descriptor numbers, including zero as
an open timeslot.

Change-Id: I67bc5ca25620ff96441391798f761144570c8306
Related: OS#5983
---
M src/input/e1d.c
1 file changed, 23 insertions(+), 7 deletions(-)

Approvals:
  pespin: Looks good to me, but someone else must approve
  msuraev: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved
  Jenkins Builder: Verified




diff --git a/src/input/e1d.c b/src/input/e1d.c
index 88b4548..e1a1526 100644
--- a/src/input/e1d.c
+++ b/src/input/e1d.c
@@ -427,17 +427,17 @@
                                lapd_instance_free(e1i_ts->lapd);
                                e1i_ts->lapd = NULL;
                        }
-                       if (bfd->fd) {
+                       if (bfd->fd >= 0) {
                                close(bfd->fd);
                                bfd->fd = -1;
                        }
                         continue;
                case E1INP_TS_TYPE_SIGN:
-                       if (bfd->fd > 0 && ts_info[ts].cfg.mode != 
E1DP_TSMODE_HDLCFCS) {
+                       if (bfd->fd >= 0 && ts_info[ts].cfg.mode != 
E1DP_TSMODE_HDLCFCS) {
                                close(bfd->fd);
                                bfd->fd = -1;
                        }
-                       if (bfd->fd <= 0) {
+                       if (bfd->fd < 0) {
                                bfd->fd = osmo_e1dp_client_ts_open(g_e1d, 
e1d_intf, e1d_line, ts,
                                                                   
E1DP_TSMODE_HDLCFCS, D_BCHAN_TX_GRAN);
                        }
@@ -463,11 +463,11 @@
                                e1i_ts->lapd = NULL;
                        }
                        /* close, if old timeslot mode doesn't match new config 
*/
-                       if (bfd->fd > 0 && ts_info[ts].cfg.mode != 
E1DP_TSMODE_HDLCFCS) {
+                       if (bfd->fd >= 0 && ts_info[ts].cfg.mode != 
E1DP_TSMODE_HDLCFCS) {
                                close(bfd->fd);
                                bfd->fd = -1;
                        }
-                       if (bfd->fd <= 0) {
+                       if (bfd->fd < 0) {
                                bfd->fd = osmo_e1dp_client_ts_open(g_e1d, 
e1d_intf, e1d_line, ts,
                                                                   
E1DP_TSMODE_HDLCFCS, D_BCHAN_TX_GRAN);
                        }
@@ -487,11 +487,11 @@
                                e1i_ts->lapd = NULL;
                        }
                        /* close, if old timeslot mode doesn't match new config 
*/
-                       if (bfd->fd > 0 && ts_info[ts].cfg.mode != 
E1DP_TSMODE_RAW) {
+                       if (bfd->fd >= 0 && ts_info[ts].cfg.mode != 
E1DP_TSMODE_RAW) {
                                close(bfd->fd);
                                bfd->fd = -1;
                        }
-                       if (bfd->fd <= 0) {
+                       if (bfd->fd < 0) {
                                bfd->fd = osmo_e1dp_client_ts_open(g_e1d, 
e1d_intf, e1d_line, ts,
                                                                   
E1DP_TSMODE_RAW, D_BCHAN_TX_GRAN);
                        }

--
To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/32402
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Change-Id: I67bc5ca25620ff96441391798f761144570c8306
Gerrit-Change-Number: 32402
Gerrit-PatchSet: 6
Gerrit-Owner: dexter <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: msuraev <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-MessageType: merged

Reply via email to