r3590 - in trunk: libminisip/source libmsip/source
Erik Eliasson
ere at kth.se
Thu Aug 21 09:35:59 CEST 2008
I agree :)
--Erik
On Wed, 2008-08-20 at 16:15 +0200, Cesc Santa wrote:
> I cannot believe this didn't got fixed earlier :)
>
> On 8/20/08, erik at minisip.org <erik at minisip.org> wrote:
> Author: erik
> Date: 2008-08-20 15:55:11 +0200 (Wed, 20 Aug 2008)
> New Revision: 3590
>
> Modified:
> trunk/libminisip/source/Minisip.cxx
> trunk/libmsip/source/SipStackInternal.cxx
> Log:
>
> * You can configure what SIP port minisip will use. Before,
> minisip
> aborted with an error message to the console when the desired
> port
> was already taken. Now a random port is chosen if the desired
> one
> fails.
>
>
>
>
> Modified: trunk/libminisip/source/Minisip.cxx
> ===================================================================
> --- trunk/libminisip/source/Minisip.cxx 2008-07-17 10:15:42
> UTC (rev 3589)
> +++ trunk/libminisip/source/Minisip.cxx 2008-08-20 13:55:11
> UTC (rev 3590)
> @@ -352,7 +352,21 @@
> // FIXME: This should be done more often
> localIpString = externalContactIP =
> ipProvider->getExternalIp();
>
> - MRef<UDPSocket*> udpSocket = new
> UDPSocket( phoneConf->sipStackConfig->preferedLocalSipPort );
> + bool done;
> + int port =
> phoneConf->sipStackConfig->preferedLocalSipPort;
> + MRef<UDPSocket*> udpSocket;
> + int ntries = 8;
> + do{
> + done=true;
> + try{
> + udpSocket = new
> UDPSocket( port );
> + }catch(NetworkException &){
> +
> phoneConf->sipStackConfig->preferedLocalSipPort = port = 32768
> +rand()%32000;
> + done=false;
> +
> + }
> + ntries--;
> + }while (!done && ntries>0);
>
> // TODO call getExternalPort on the real
> UDPSocket:s
> // when they are created
>
> Modified: trunk/libmsip/source/SipStackInternal.cxx
> ===================================================================
> --- trunk/libmsip/source/SipStackInternal.cxx 2008-07-17
> 10:15:42 UTC (rev 3589)
> +++ trunk/libmsip/source/SipStackInternal.cxx 2008-08-20
> 13:55:11 UTC (rev 3590)
> @@ -507,13 +507,25 @@
> }
> }
>
> -
> dispatcher->getLayerTransport()->startServer( transport,
> - ipString,
> - config->localIp6String,
> - port,
> - externalUdpPort,
> - config->cert,
> - config->cert_db );
> + bool done=false;
> + int ntries=8;
> + while (!done && ntries>0){
> +
> + try{
> +
> dispatcher->getLayerTransport()->startServer( transport,
> + ipString,
> +
> config->localIp6String,
> + port,
> + externalUdpPort,
> + config->cert,
> + config->cert_db );
> + done=true;
> + }catch(Exception &e){
> + port = config->externalContactUdpPort
> = rand()%32000+32000;
> + }catch(...){
> + throw;
> + }
> + }
> }
>
>
>
> _______________________________________________
> Minisip-devel mailing list
> Minisip-devel at minisip.org
> http://lists.minisip.org/mailman/listinfo/minisip-devel
>
More information about the Minisip-devel
mailing list