diff options
author | murf <murf@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-11-07 23:46:41 +0000 |
---|---|---|
committer | murf <murf@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-11-07 23:46:41 +0000 |
commit | c25499d6c75ea145820465178ef982d256432bc6 (patch) | |
tree | de5d3b24e69a5cd86813ecf37bdeb5c9f87059a9 /channels/chan_sip.c | |
parent | b3c737f0114f072f2c01eab99cfd6265fd6a1264 (diff) |
These mods are to solve the problem in bug 7506. It's a lot of rework to solve a fairly small problem... such is life.
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@47303 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_sip.c')
-rw-r--r-- | channels/chan_sip.c | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 9b744f076..bbcb91829 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -3686,10 +3686,21 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit int fmt; int what; int needvideo = 0; - - ast_mutex_unlock(&i->lock); - /* Don't hold a sip pvt lock while we allocate a channel */ - tmp = ast_channel_alloc(1); + { + const char *my_name; /* pick a good name */ + + if (title) + my_name = title; + else if ( (my_name = strchr(i->fromdomain,':')) ) + my_name++; /* skip ':' */ + else + my_name = i->fromdomain; + + 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, "SIP/%s-%08x", my_name, (int)(long) i); + + } ast_mutex_lock(&i->lock); if (!tmp) { ast_log(LOG_WARNING, "Unable to allocate AST channel structure for SIP channel\n"); @@ -3740,16 +3751,6 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit } - { - const char *my_name; /* pick a good name */ - if (title) - my_name = title; - else if ( (my_name = strchr(i->fromdomain,':')) ) - my_name++; /* skip ':' */ - else - my_name = i->fromdomain; - ast_string_field_build(tmp, name, "SIP/%s-%08x", my_name, (int)(long) i); - } if (ast_test_flag(&i->flags[0], SIP_DTMF) == SIP_DTMF_INBAND) { i->vad = ast_dsp_new(); @@ -3793,7 +3794,7 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit ast_copy_string(tmp->exten, i->exten, sizeof(tmp->exten)); /* Don't use ast_set_callerid() here because it will - * generate a NewCallerID event before the NewChannel event */ + * generate an unnecessary NewCallerID event */ tmp->cid.cid_num = ast_strdup(i->cid_num); tmp->cid.cid_ani = ast_strdup(i->cid_num); tmp->cid.cid_name = ast_strdup(i->cid_name); @@ -3812,7 +3813,6 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit pbx_builtin_setvar_helper(tmp, "SIPUSERAGENT", i->useragent); if (!ast_strlen_zero(i->callid)) pbx_builtin_setvar_helper(tmp, "SIPCALLID", i->callid); - ast_setstate(tmp, state); if (i->rtp) ast_jb_configure(tmp, &global_jbconf); if (state != AST_STATE_DOWN && ast_pbx_start(tmp)) { @@ -12316,8 +12316,8 @@ static int sip_park(struct ast_channel *chan1, struct ast_channel *chan2, struct /* Chan2m: The transferer, chan1m: The transferee */ pthread_t th; - transferee = ast_channel_alloc(0); - transferer = ast_channel_alloc(0); + transferee = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, "Parking/%s", chan1->name); + transferer = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, "SIPPeer/%s", chan2->name); if ((!transferer) || (!transferee)) { if (transferee) { transferee->hangupcause = AST_CAUSE_SWITCH_CONGESTION; @@ -12329,7 +12329,6 @@ static int sip_park(struct ast_channel *chan1, struct ast_channel *chan2, struct } return -1; } - ast_string_field_build(transferee, name, "Parking/%s", chan1->name); /* Make formats okay */ transferee->readformat = chan1->readformat; @@ -12345,7 +12344,6 @@ static int sip_park(struct ast_channel *chan1, struct ast_channel *chan2, struct /* We make a clone of the peer channel too, so we can play back the announcement */ - ast_string_field_build(transferer, name, "SIPPeer/%s", chan2->name); /* Make formats okay */ transferer->readformat = chan2->readformat; |