mirror of
https://github.com/PentHertz/OpenBTS.git
synced 2026-05-02 13:20:05 +00:00
Fixes #711 in private. We now check RTP ports before allocation, to ensure they're not already in use.
git-svn-id: http://wush.net/svn/range/software/public/openbts/trunk@3225 19bc5d8c-e614-43d4-8b26-e1612bc8e597
This commit is contained in:
parent
56dd0dd9df
commit
3f264a9e86
5 changed files with 33 additions and 4 deletions
|
|
@ -72,17 +72,20 @@ using namespace Control;
|
|||
*/
|
||||
unsigned allocateRTPPorts()
|
||||
{
|
||||
// FIXME -- We need a real port allocator.
|
||||
const unsigned base = gConfig.getNum("RTP.Start");
|
||||
const unsigned range = gConfig.getNum("RTP.Range");
|
||||
const unsigned top = base+range;
|
||||
static Mutex lock;
|
||||
// Pick a random starting point.
|
||||
static unsigned port = base + 2*(random()%(range/2));
|
||||
unsigned retVal;
|
||||
lock.lock();
|
||||
unsigned retVal = port;
|
||||
port += 2;
|
||||
if (port>=top) port=base;
|
||||
//This is a little hacky as RTPAvail is O(n)
|
||||
do {
|
||||
retVal = port;
|
||||
port += 2;
|
||||
if (port>=top) port=base;
|
||||
} while (!gTransactionTable.RTPAvailable(retVal));
|
||||
lock.unlock();
|
||||
return retVal;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue