diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-08-06 07:18:22 +0800 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-08-08 07:23:58 +0800 |
commit | 55228e31be5b0d25115b9b19549f757ca460c0ee (patch) | |
tree | bc3ae1aa0f8e0554275703aa58acbf166635ee0f | |
parent | db544db73af0638fa822d8e09eb169cc5b08f65c (diff) |
mgcp: Add instrumentation code to find a possible port leak/bsc-fd corruption
-rw-r--r-- | openbsc/src/mgcp/mgcp_network.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/openbsc/src/mgcp/mgcp_network.c b/openbsc/src/mgcp/mgcp_network.c index 35cc7329f..15097bfc1 100644 --- a/openbsc/src/mgcp/mgcp_network.c +++ b/openbsc/src/mgcp/mgcp_network.c @@ -409,6 +409,12 @@ cleanup0: int mgcp_bind_bts_rtp_port(struct mgcp_endpoint *endp, int rtp_port) { + if (endp->bts_end.rtp.fd != -1 || endp->bts_end.rtcp.fd != -1) { + LOGP(DMGCP, LOGL_ERROR, "Previous bts-port was still bound on %d\n", + ENDPOINT_NUMBER(endp)); + mgcp_free_rtp_port(&endp->bts_end); + } + endp->bts_end.local_port = rtp_port; endp->bts_end.rtp.cb = rtp_data_bts; endp->bts_end.rtp.data = endp; @@ -419,6 +425,12 @@ int mgcp_bind_bts_rtp_port(struct mgcp_endpoint *endp, int rtp_port) int mgcp_bind_net_rtp_port(struct mgcp_endpoint *endp, int rtp_port) { + if (endp->net_end.rtp.fd != -1 || endp->net_end.rtcp.fd != -1) { + LOGP(DMGCP, LOGL_ERROR, "Previous net-port was still bound on %d\n", + ENDPOINT_NUMBER(endp)); + mgcp_free_rtp_port(&endp->net_end); + } + endp->net_end.local_port = rtp_port; endp->net_end.rtp.cb = rtp_data_net; endp->net_end.rtp.data = endp; @@ -429,11 +441,6 @@ int mgcp_bind_net_rtp_port(struct mgcp_endpoint *endp, int rtp_port) int mgcp_free_rtp_port(struct mgcp_rtp_end *end) { - if (end->local_alloc != PORT_ALLOC_DYNAMIC) { - LOGP(DMGCP, LOGL_ERROR, "Should only be called for dynamic ports.\n"); - return -1; - } - if (end->rtp.fd != -1) { close(end->rtp.fd); end->rtp.fd = -1; |