From 1168d13e0c9e2ba3c9bc9fa7cfe419d0a51455a4 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Thu, 7 Oct 2010 04:52:22 +0800 Subject: msc: Only unregister the fd if the fd value is valid. This makes sure that someone can call bsc_msc_lost multiple times even if there is no MSC connection. This makes sense as bsc_msc_lost is public and be called from client code. --- openbsc/src/bsc_msc.c | 4 +++- openbsc/src/bsc_msc_ip.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/openbsc/src/bsc_msc.c b/openbsc/src/bsc_msc.c index a78a1416d..ed7477953 100644 --- a/openbsc/src/bsc_msc.c +++ b/openbsc/src/bsc_msc.c @@ -217,7 +217,9 @@ void bsc_msc_lost(struct bsc_msc_connection *con) { write_queue_clear(&con->write_queue); bsc_del_timer(&con->timeout_timer); - bsc_unregister_fd(&con->write_queue.bfd); + + if (con->write_queue.bfd.fd >= 0) + bsc_unregister_fd(&con->write_queue.bfd); connection_loss(con); } diff --git a/openbsc/src/bsc_msc_ip.c b/openbsc/src/bsc_msc_ip.c index ace9eb775..82fd7f402 100644 --- a/openbsc/src/bsc_msc_ip.c +++ b/openbsc/src/bsc_msc_ip.c @@ -1178,7 +1178,7 @@ static void signal_handler(int signal) talloc_report_full(tall_bsc_ctx, stderr); break; case SIGUSR2: - if (!bsc_gsmnet->msc_con || !bsc_gsmnet->msc_con->is_connected) + if (!bsc_gsmnet->msc_con) return; bsc_msc_lost(bsc_gsmnet->msc_con); break; -- cgit v1.2.3