From ade60edd5f7aedcd618dbabda04ab11f3e3be20d Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Fri, 25 Nov 2011 15:31:15 +0100 Subject: msc: Only unregister the fd when we have a valid fd --- src/msc_conn.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/msc_conn.c') diff --git a/src/msc_conn.c b/src/msc_conn.c index 452d408..edfd521 100644 --- a/src/msc_conn.c +++ b/src/msc_conn.c @@ -55,9 +55,12 @@ void msc_close_connection(struct msc_connection *fw) { struct osmo_fd *bfd = &fw->msc_connection.bfd; - close(bfd->fd); - osmo_fd_unregister(bfd); - bfd->fd = -1; + if (bfd->fd >= 0) { + close(bfd->fd); + osmo_fd_unregister(bfd); + bfd->fd = -1; + } + fw->msc_link_down = 1; release_bsc_resources(fw); osmo_timer_del(&fw->ping_timeout); @@ -547,6 +550,7 @@ struct msc_connection *msc_connection_create(struct bsc_data *bsc, int mgcp) msc->msc_connection.read_cb = ipaccess_a_fd_cb; msc->msc_connection.write_cb = ipaccess_write_cb; msc->msc_connection.bfd.data = msc; + msc->msc_connection.bfd.fd = -1; msc->msc_link_down = 1; /* handle the timeout */ -- cgit v1.2.3