From 9d1a17e15f6902bc9591680da3375b2d14db16ab Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Wed, 21 Jan 2015 16:53:53 +0100 Subject: osmux: Initialize the socket only once The per BSC code didn't guard against the init already having been executed. This lead to: Adding a osmo_fd that is already in the list. <000b> bsc_nat_vty.c:1200 Setting up OSMUX socket So a new socket got created and the old one leaked. Luckily Linux appears to allow to bind multiple times so we were able to just read from the new one. Use the same guard that is used on the MGCP MGW. Re-order the log message to say "Setting up" before we actually do that. I manually verified that osmux_init is called at most once. The log message was spotted by Roch --- openbsc/src/osmo-bsc_nat/bsc_nat_vty.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c index 5229976af..5f4ad284e 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c @@ -1192,12 +1192,14 @@ DEFUN(cfg_bsc_osmux, else if (strcmp(argv[0], "off") == 0) conf->osmux = 0; - if (old == 0 && conf->osmux == 1) { + if (old == 0 && conf->osmux == 1 && !conf->nat->mgcp_cfg->osmux_init) { + LOGP(DMGCP, LOGL_NOTICE, "Setting up OSMUX socket\n"); if (osmux_init(OSMUX_ROLE_BSC_NAT, conf->nat->mgcp_cfg) < 0) { LOGP(DMGCP, LOGL_ERROR, "Cannot init OSMUX\n"); - return -1; + vty_out(vty, "%% failed to create Osmux socket%s", + VTY_NEWLINE); + return CMD_WARNING; } - LOGP(DMGCP, LOGL_NOTICE, "Setting up OSMUX socket\n"); } else if (old == 1 && conf->osmux == 0) { LOGP(DMGCP, LOGL_NOTICE, "Disabling OSMUX socket\n"); /* Don't stop the socket, we may already have ongoing voice -- cgit v1.2.3