]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
SIP channel name uniqueness
authorDavid Brooks <dbrooks@digium.com>
Mon, 2 Nov 2009 20:52:53 +0000 (20:52 +0000)
committerDavid Brooks <dbrooks@digium.com>
Mon, 2 Nov 2009 20:52:53 +0000 (20:52 +0000)
SIP channel names were supposed to be unique by way of a name suffix derived from the
pointer to the channel's private data. Uniqueness was preserved on 32-bit systems, but
not on 64-bit systems. This patch, as suggested by kpfleming, replaces this suffix with
a simple incremented unsigned int.

(closes issue #15152)
Reported by: palbrecht

Review: https://reviewboard.asterisk.org/r/420/

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@226972 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index f5a45b2a5f192aa12179419bd776f872f9e718e0..7a53c106f3d91b3464ad72ff407b366fe7c6b1d6 100644 (file)
@@ -398,6 +398,8 @@ static const struct  cfsip_methods {
        { SIP_PING,      NO_RTP, "PING",        CAN_CREATE_DIALOG_UNSUPPORTED_METHOD }
 };
 
+static unsigned int chan_idx;
+
 /*!  Define SIP option tags, used in Require: and Supported: headers 
        We need to be aware of these properties in the phones to use 
        the replace: header. We should not do that without knowing
@@ -4207,7 +4209,7 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
 
                ast_mutex_unlock(&i->lock);
                /* Don't hold a sip pvt lock while we allocate a channel */
-               tmp = ast_channel_alloc(1, state, i->cid_num, i->cid_name, i->accountcode, i->exten, i->context, i->amaflags, "SIP/%s-%08x", my_name, (int)(long) i);
+               tmp = ast_channel_alloc(1, state, i->cid_num, i->cid_name, i->accountcode, i->exten, i->context, i->amaflags, "SIP/%s-%08x", my_name, ast_atomic_fetchadd_int((int *)&chan_idx, +1));
 
        }
        if (!tmp) {