aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-03-24 11:20:27 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-03-24 11:23:39 +0100
commitad9856ec15645f06859d238ac86eaaa237b51bdf (patch)
tree0b9e6b7995c33e4c7b3db4ab4b21350d7311fd3d
parent9d53a8ad2a48a5b339b971f2dd57287d2211ca81 (diff)
ipa: Fix the previous patch and initialize the fds to -1
The code in 354ef81d8062510765b7280023b3f4ef98d0613a checked for fd >= 0 but on startup the struct is memset to 0 so this test is true. Initialize the fds to -1 to make the code work and be able to handle all ranges of the fd.
-rw-r--r--openbsc/src/input/ipaccess.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/openbsc/src/input/ipaccess.c b/openbsc/src/input/ipaccess.c
index aa598dfb..8ebb83be 100644
--- a/openbsc/src/input/ipaccess.c
+++ b/openbsc/src/input/ipaccess.c
@@ -247,6 +247,7 @@ static int ipaccess_rcvmsg(struct e1inp_line *line, struct msgb *msg,
LOGP(DINP, LOGL_ERROR, "BTS is still registered. Closing old connection.\n");
bsc_unregister_fd(newbfd);
close(newbfd->fd);
+ newbfd->fd = -1;
}
/* get rid of our old temporary bfd */
@@ -491,6 +492,7 @@ static int listen_fd_cb(struct bsc_fd *listen_bfd, unsigned int what)
{
int ret;
int idx = 0;
+ int i;
struct e1inp_line *line;
struct e1inp_ts *e1i_ts;
struct bsc_fd *bfd;
@@ -517,6 +519,10 @@ static int listen_fd_cb(struct bsc_fd *listen_bfd, unsigned int what)
/* create virrtual E1 timeslots for signalling */
e1inp_ts_config(&line->ts[1-1], line, E1INP_TS_TYPE_SIGN);
+ /* initialize the fds */
+ for (i = 0; i < ARRAY_SIZE(line->ts); ++i)
+ line->ts[i].driver.ipaccess.fd.fd = -1;
+
e1i_ts = &line->ts[idx];
bfd = &e1i_ts->driver.ipaccess.fd;