Merged revisions 43783 via svnmerge from

https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r43783 | file | 2006-09-27 13:00:31 -0400 (Wed, 27 Sep 2006) | 2 lines

Get rid of two functions from a time now past (we THINK these are from pre-recursive lock time) that may be contributing to two open issues on the bug tracker (7562/7939) and that has the potential to just make bad things happen if the timing is right.

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@43792 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.6.0
Joshua Colp 19 years ago
parent 6b3a6a1104
commit a5770f4e72

@ -1699,15 +1699,6 @@ static int iax2_predestroy(int callno)
return 0; return 0;
} }
static int iax2_predestroy_nolock(int callno)
{
int res;
ast_mutex_unlock(&iaxsl[callno]);
res = iax2_predestroy(callno);
ast_mutex_lock(&iaxsl[callno]);
return res;
}
static void iax2_destroy(int callno) static void iax2_destroy(int callno)
{ {
struct chan_iax2_pvt *pvt = NULL; struct chan_iax2_pvt *pvt = NULL;
@ -1774,13 +1765,6 @@ retry:
if (callno & 0x4000) if (callno & 0x4000)
update_max_trunk(); update_max_trunk();
} }
static void iax2_destroy_nolock(int callno)
{
/* Actually it's easier to unlock, kill it, and relock */
ast_mutex_unlock(&iaxsl[callno]);
iax2_destroy(callno);
ast_mutex_lock(&iaxsl[callno]);
}
static int update_packet(struct iax_frame *f) static int update_packet(struct iax_frame *f)
{ {
@ -1815,7 +1799,7 @@ static void __attempt_transmit(void *data)
send_command(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_TXREJ, 0, NULL, 0, -1); send_command(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_TXREJ, 0, NULL, 0, -1);
} else if (f->final) { } else if (f->final) {
if (f->final) if (f->final)
iax2_destroy_nolock(callno); iax2_destroy(callno);
} else { } else {
if (iaxs[callno]->owner) if (iaxs[callno]->owner)
ast_log(LOG_WARNING, "Max retries exceeded to host %s on %s (type = %d, subclass = %d, ts=%d, seqno=%d)\n", ast_inet_ntoa(iaxs[f->callno]->addr.sin_addr),iaxs[f->callno]->owner->name , f->af.frametype, f->af.subclass, f->ts, f->oseqno); ast_log(LOG_WARNING, "Max retries exceeded to host %s on %s (type = %d, subclass = %d, ts=%d, seqno=%d)\n", ast_inet_ntoa(iaxs[f->callno]->addr.sin_addr),iaxs[f->callno]->owner->name , f->af.frametype, f->af.subclass, f->ts, f->oseqno);
@ -1835,7 +1819,7 @@ static void __attempt_transmit(void *data)
iaxs[callno]->reg->regstate = REG_STATE_TIMEOUT; iaxs[callno]->reg->regstate = REG_STATE_TIMEOUT;
iaxs[callno]->reg->refresh = IAX_DEFAULT_REG_EXPIRE; iaxs[callno]->reg->refresh = IAX_DEFAULT_REG_EXPIRE;
} }
iax2_destroy_nolock(callno); iax2_destroy(callno);
} }
} }
@ -2924,11 +2908,11 @@ static int iax2_hangup(struct ast_channel *c)
if (!iaxs[callno]->error && !alreadygone) if (!iaxs[callno]->error && !alreadygone)
send_command_final(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_HANGUP, 0, ied.buf, ied.pos, -1); send_command_final(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_HANGUP, 0, ied.buf, ied.pos, -1);
/* Explicitly predestroy it */ /* Explicitly predestroy it */
iax2_predestroy_nolock(callno); iax2_predestroy(callno);
/* If we were already gone to begin with, destroy us now */ /* If we were already gone to begin with, destroy us now */
if (alreadygone) { if (alreadygone) {
ast_log(LOG_DEBUG, "Really destroying %s now...\n", c->name); ast_log(LOG_DEBUG, "Really destroying %s now...\n", c->name);
iax2_destroy_nolock(callno); iax2_destroy(callno);
} }
} }
ast_mutex_unlock(&iaxsl[callno]); ast_mutex_unlock(&iaxsl[callno]);
@ -4523,7 +4507,7 @@ static int send_command_locked(unsigned short callno, char type, int command, un
static int send_command_final(struct chan_iax2_pvt *i, char type, int command, unsigned int ts, const unsigned char *data, int datalen, int seqno) static int send_command_final(struct chan_iax2_pvt *i, char type, int command, unsigned int ts, const unsigned char *data, int datalen, int seqno)
{ {
/* It is assumed that the callno has already been locked */ /* It is assumed that the callno has already been locked */
iax2_predestroy_nolock(i->callno); iax2_predestroy(i->callno);
return __send_command(i, type, command, ts, data, datalen, seqno, 0, 0, 1); return __send_command(i, type, command, ts, data, datalen, seqno, 0, 0, 1);
} }
@ -6563,7 +6547,7 @@ static int socket_process(struct iax2_thread *thread)
if (cur->final) { if (cur->final) {
if (iaxdebug && option_debug) if (iaxdebug && option_debug)
ast_log(LOG_DEBUG, "Really destroying %d, having been acked on final message\n", fr->callno); ast_log(LOG_DEBUG, "Really destroying %d, having been acked on final message\n", fr->callno);
iax2_destroy_nolock(fr->callno); iax2_destroy(fr->callno);
} }
} }
} }
@ -6871,7 +6855,7 @@ retryowner:
using_prefs); using_prefs);
if(!(c = ast_iax2_new(fr->callno, AST_STATE_RING, format))) if(!(c = ast_iax2_new(fr->callno, AST_STATE_RING, format)))
iax2_destroy_nolock(fr->callno); iax2_destroy(fr->callno);
} else { } else {
ast_set_flag(&iaxs[fr->callno]->state, IAX_STATE_TBD); ast_set_flag(&iaxs[fr->callno]->state, IAX_STATE_TBD);
/* If this is a TBD call, we're ready but now what... */ /* If this is a TBD call, we're ready but now what... */
@ -6910,7 +6894,7 @@ retryowner:
iaxs[fr->callno]->owner->hangupcause = ies.causecode; iaxs[fr->callno]->owner->hangupcause = ies.causecode;
/* Send ack immediately, before we destroy */ /* Send ack immediately, before we destroy */
send_command_immediate(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_ACK, fr->ts, NULL, 0,fr->iseqno); send_command_immediate(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_ACK, fr->ts, NULL, 0,fr->iseqno);
iax2_destroy_nolock(fr->callno); iax2_destroy(fr->callno);
break; break;
case IAX_COMMAND_REJECT: case IAX_COMMAND_REJECT:
/* Set hangup cause according to remote */ /* Set hangup cause according to remote */
@ -6930,7 +6914,7 @@ retryowner:
fr->ts, NULL, 0, fr->iseqno); fr->ts, NULL, 0, fr->iseqno);
if (!ast_test_flag(iaxs[fr->callno], IAX_PROVISION)) if (!ast_test_flag(iaxs[fr->callno], IAX_PROVISION))
iaxs[fr->callno]->error = EPERM; iaxs[fr->callno]->error = EPERM;
iax2_destroy_nolock(fr->callno); iax2_destroy(fr->callno);
break; break;
case IAX_COMMAND_TRANSFER: case IAX_COMMAND_TRANSFER:
if (iaxs[fr->callno]->owner && ast_bridged_channel(iaxs[fr->callno]->owner) && ies.called_number) { if (iaxs[fr->callno]->owner && ast_bridged_channel(iaxs[fr->callno]->owner) && ies.called_number) {
@ -6960,7 +6944,7 @@ retryowner:
if (ast_test_flag(iaxs[fr->callno], IAX_PROVISION)) { if (ast_test_flag(iaxs[fr->callno], IAX_PROVISION)) {
/* Send ack immediately, before we destroy */ /* Send ack immediately, before we destroy */
send_command_immediate(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_ACK, fr->ts, NULL, 0,fr->iseqno); send_command_immediate(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_ACK, fr->ts, NULL, 0,fr->iseqno);
iax2_destroy_nolock(fr->callno); iax2_destroy(fr->callno);
break; break;
} }
if (ies.format) { if (ies.format) {
@ -7063,7 +7047,7 @@ retryowner2:
/* and finally send the ack */ /* and finally send the ack */
send_command_immediate(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_ACK, fr->ts, NULL, 0,fr->iseqno); send_command_immediate(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_ACK, fr->ts, NULL, 0,fr->iseqno);
/* And wrap up the qualify call */ /* And wrap up the qualify call */
iax2_destroy_nolock(fr->callno); iax2_destroy(fr->callno);
peer->callno = 0; peer->callno = 0;
if (option_debug) if (option_debug)
ast_log(LOG_DEBUG, "Peer %s: got pong, lastms %d, historicms %d, maxms %d\n", peer->name, peer->lastms, peer->historicms, peer->maxms); ast_log(LOG_DEBUG, "Peer %s: got pong, lastms %d, historicms %d, maxms %d\n", peer->name, peer->lastms, peer->historicms, peer->maxms);
@ -7247,7 +7231,7 @@ retryowner2:
ast_set_flag(&iaxs[fr->callno]->state, IAX_STATE_STARTED); ast_set_flag(&iaxs[fr->callno]->state, IAX_STATE_STARTED);
if(!(c = ast_iax2_new(fr->callno, AST_STATE_RING, format))) if(!(c = ast_iax2_new(fr->callno, AST_STATE_RING, format)))
iax2_destroy_nolock(fr->callno); iax2_destroy(fr->callno);
} else { } else {
ast_set_flag(&iaxs[fr->callno]->state, IAX_STATE_TBD); ast_set_flag(&iaxs[fr->callno]->state, IAX_STATE_TBD);
/* If this is a TBD call, we're ready but now what... */ /* If this is a TBD call, we're ready but now what... */
@ -7275,14 +7259,14 @@ retryowner2:
ast_set_flag(&iaxs[fr->callno]->state, IAX_STATE_STARTED); ast_set_flag(&iaxs[fr->callno]->state, IAX_STATE_STARTED);
send_command(iaxs[fr->callno], AST_FRAME_CONTROL, AST_CONTROL_PROGRESS, 0, NULL, 0, -1); send_command(iaxs[fr->callno], AST_FRAME_CONTROL, AST_CONTROL_PROGRESS, 0, NULL, 0, -1);
if(!(c = ast_iax2_new(fr->callno, AST_STATE_RING, iaxs[fr->callno]->peerformat))) if(!(c = ast_iax2_new(fr->callno, AST_STATE_RING, iaxs[fr->callno]->peerformat)))
iax2_destroy_nolock(fr->callno); iax2_destroy(fr->callno);
} }
} }
break; break;
case IAX_COMMAND_INVAL: case IAX_COMMAND_INVAL:
iaxs[fr->callno]->error = ENOTCONN; iaxs[fr->callno]->error = ENOTCONN;
ast_log(LOG_DEBUG, "Immediately destroying %d, having received INVAL\n", fr->callno); ast_log(LOG_DEBUG, "Immediately destroying %d, having received INVAL\n", fr->callno);
iax2_destroy_nolock(fr->callno); iax2_destroy(fr->callno);
if (option_debug) if (option_debug)
ast_log(LOG_DEBUG, "Destroying call %d\n", fr->callno); ast_log(LOG_DEBUG, "Destroying call %d\n", fr->callno);
break; break;
@ -7318,7 +7302,7 @@ retryowner2:
ast_log(LOG_WARNING, "Registration failure\n"); ast_log(LOG_WARNING, "Registration failure\n");
/* Send ack immediately, before we destroy */ /* Send ack immediately, before we destroy */
send_command_immediate(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_ACK, fr->ts, NULL, 0,fr->iseqno); send_command_immediate(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_ACK, fr->ts, NULL, 0,fr->iseqno);
iax2_destroy_nolock(fr->callno); iax2_destroy(fr->callno);
break; break;
case IAX_COMMAND_REGREJ: case IAX_COMMAND_REGREJ:
if (iaxs[fr->callno]->reg) { if (iaxs[fr->callno]->reg) {
@ -7330,7 +7314,7 @@ retryowner2:
} }
/* Send ack immediately, before we destroy */ /* Send ack immediately, before we destroy */
send_command_immediate(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_ACK, fr->ts, NULL, 0,fr->iseqno); send_command_immediate(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_ACK, fr->ts, NULL, 0,fr->iseqno);
iax2_destroy_nolock(fr->callno); iax2_destroy(fr->callno);
break; break;
case IAX_COMMAND_REGAUTH: case IAX_COMMAND_REGAUTH:
/* Authentication request */ /* Authentication request */
@ -8620,7 +8604,7 @@ static void delete_users(void)
ast_mutex_lock(&iaxsl[regl->callno]); ast_mutex_lock(&iaxsl[regl->callno]);
if (iaxs[regl->callno]) { if (iaxs[regl->callno]) {
iaxs[regl->callno]->reg = NULL; iaxs[regl->callno]->reg = NULL;
iax2_destroy_nolock(regl->callno); iax2_destroy(regl->callno);
} }
ast_mutex_unlock(&iaxsl[regl->callno]); ast_mutex_unlock(&iaxsl[regl->callno]);
} }

Loading…
Cancel
Save