--- ../clean/asterisk-1.6.2.17-rc2/channels/chan_sip.c 2011-01-12 23:05:02.000000000 +0200 +++ channels/chan_sip.c 2011-02-17 14:16:09.000000000 +0200 @@ -7154,6 +7154,12 @@ sip_pvt_lock(p); fr = sip_rtp_read(ast, p, &faxdetected); + + if (((fr == &ast_null_frame) && p->rtp && !ast_rtp_get_bridged(p->rtp)) || (!p->rtp)) { + sip_pvt_unlock(p); + return fr; + } + p->lastrtprx = time(NULL); /* If we detect a CNG tone and fax detection is enabled then send us off to the fax extension */ @@ -22686,14 +22692,10 @@ (t > dialog->lastrtprx + ast_rtp_get_rtpholdtimeout(dialog->rtp)))) { /* Needs a hangup */ if (ast_rtp_get_rtptimeout(dialog->rtp)) { - while (dialog->owner && ast_channel_trylock(dialog->owner)) { - sip_pvt_unlock(dialog); - usleep(1); - sip_pvt_lock(dialog); - } - if (!dialog->owner) { - return; /* channel hangup can occur during deadlock avoidance. */ - } + /* Don't block the monitor thread. This function is called often enough + * that we can wait for the next time around. */ + if ((!dialog->owner) || (dialog->owner && ast_channel_trylock(dialog->owner))) + return; ast_log(LOG_NOTICE, "Disconnecting call '%s' for lack of RTP activity in %ld seconds\n", dialog->owner->name, (long) (t - dialog->lastrtprx)); /* Issue a softhangup */