|
|
@ -14575,52 +14575,9 @@ static int does_peer_need_mwi(struct sip_peer *peer)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*! \brief The SIP monitoring thread
|
|
|
|
/*! \brief helper function for the monitoring thread */
|
|
|
|
\note This thread monitors all the SIP sessions and peers that needs notification of mwi
|
|
|
|
static void check_rtp_timeout(struct sip_pvt *sip, time_t t)
|
|
|
|
(and thus do not have a separate thread) indefinitely
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void *do_monitor(void *data)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
|
|
|
|
struct sip_pvt *sip;
|
|
|
|
|
|
|
|
struct sip_peer *peer = NULL;
|
|
|
|
|
|
|
|
time_t t;
|
|
|
|
|
|
|
|
int fastrestart = FALSE;
|
|
|
|
|
|
|
|
int lastpeernum = -1;
|
|
|
|
|
|
|
|
int curpeernum;
|
|
|
|
|
|
|
|
int reloading;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Add an I/O event to our SIP UDP socket */
|
|
|
|
|
|
|
|
if (sipsock > -1)
|
|
|
|
|
|
|
|
sipsock_read_id = ast_io_add(io, sipsock, sipsock_read, AST_IO_IN, NULL);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* From here on out, we die whenever asked */
|
|
|
|
|
|
|
|
for(;;) {
|
|
|
|
|
|
|
|
/* Check for a reload request */
|
|
|
|
|
|
|
|
ast_mutex_lock(&sip_reload_lock);
|
|
|
|
|
|
|
|
reloading = sip_reloading;
|
|
|
|
|
|
|
|
sip_reloading = FALSE;
|
|
|
|
|
|
|
|
ast_mutex_unlock(&sip_reload_lock);
|
|
|
|
|
|
|
|
if (reloading) {
|
|
|
|
|
|
|
|
if (option_verbose > 0)
|
|
|
|
|
|
|
|
ast_verbose(VERBOSE_PREFIX_1 "Reloading SIP\n");
|
|
|
|
|
|
|
|
sip_do_reload(sip_reloadreason);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Change the I/O fd of our UDP socket */
|
|
|
|
|
|
|
|
if (sipsock > -1)
|
|
|
|
|
|
|
|
sipsock_read_id = ast_io_change(io, sipsock_read_id, sipsock, NULL, 0, NULL);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check for interfaces needing to be killed */
|
|
|
|
|
|
|
|
ast_mutex_lock(&iflock);
|
|
|
|
|
|
|
|
restartsearch:
|
|
|
|
|
|
|
|
t = time(NULL);
|
|
|
|
|
|
|
|
/* don't scan the interface list if it hasn't been a reasonable period
|
|
|
|
|
|
|
|
of time since the last time we did it (when MWI is being sent, we can
|
|
|
|
|
|
|
|
get back to this point every millisecond or less)
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
for (sip = iflist; !fastrestart && sip; sip = sip->next) {
|
|
|
|
|
|
|
|
ast_mutex_lock(&sip->lock);
|
|
|
|
|
|
|
|
/* Check RTP timeouts and kill calls if we have a timeout set and do not get RTP */
|
|
|
|
|
|
|
|
if (sip->rtp && sip->owner &&
|
|
|
|
if (sip->rtp && sip->owner &&
|
|
|
|
(sip->owner->_state == AST_STATE_UP) &&
|
|
|
|
(sip->owner->_state == AST_STATE_UP) &&
|
|
|
|
!sip->redirip.sin_addr.s_addr) {
|
|
|
|
!sip->redirip.sin_addr.s_addr) {
|
|
|
@ -14669,6 +14626,55 @@ restartsearch:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*! \brief The SIP monitoring thread
|
|
|
|
|
|
|
|
\note This thread monitors all the SIP sessions and peers that needs notification of mwi
|
|
|
|
|
|
|
|
(and thus do not have a separate thread) indefinitely
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void *do_monitor(void *data)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int res;
|
|
|
|
|
|
|
|
struct sip_pvt *sip;
|
|
|
|
|
|
|
|
struct sip_peer *peer = NULL;
|
|
|
|
|
|
|
|
time_t t;
|
|
|
|
|
|
|
|
int fastrestart = FALSE;
|
|
|
|
|
|
|
|
int lastpeernum = -1;
|
|
|
|
|
|
|
|
int curpeernum;
|
|
|
|
|
|
|
|
int reloading;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Add an I/O event to our SIP UDP socket */
|
|
|
|
|
|
|
|
if (sipsock > -1)
|
|
|
|
|
|
|
|
sipsock_read_id = ast_io_add(io, sipsock, sipsock_read, AST_IO_IN, NULL);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* From here on out, we die whenever asked */
|
|
|
|
|
|
|
|
for(;;) {
|
|
|
|
|
|
|
|
/* Check for a reload request */
|
|
|
|
|
|
|
|
ast_mutex_lock(&sip_reload_lock);
|
|
|
|
|
|
|
|
reloading = sip_reloading;
|
|
|
|
|
|
|
|
sip_reloading = FALSE;
|
|
|
|
|
|
|
|
ast_mutex_unlock(&sip_reload_lock);
|
|
|
|
|
|
|
|
if (reloading) {
|
|
|
|
|
|
|
|
if (option_verbose > 0)
|
|
|
|
|
|
|
|
ast_verbose(VERBOSE_PREFIX_1 "Reloading SIP\n");
|
|
|
|
|
|
|
|
sip_do_reload(sip_reloadreason);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Change the I/O fd of our UDP socket */
|
|
|
|
|
|
|
|
if (sipsock > -1)
|
|
|
|
|
|
|
|
sipsock_read_id = ast_io_change(io, sipsock_read_id, sipsock, NULL, 0, NULL);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check for interfaces needing to be killed */
|
|
|
|
|
|
|
|
ast_mutex_lock(&iflock);
|
|
|
|
|
|
|
|
restartsearch:
|
|
|
|
|
|
|
|
t = time(NULL);
|
|
|
|
|
|
|
|
/* don't scan the interface list if it hasn't been a reasonable period
|
|
|
|
|
|
|
|
of time since the last time we did it (when MWI is being sent, we can
|
|
|
|
|
|
|
|
get back to this point every millisecond or less)
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
for (sip = iflist; !fastrestart && sip; sip = sip->next) {
|
|
|
|
|
|
|
|
ast_mutex_lock(&sip->lock);
|
|
|
|
|
|
|
|
/* Check RTP timeouts and kill calls if we have a timeout set and do not get RTP */
|
|
|
|
|
|
|
|
check_rtp_timeout(sip, t);
|
|
|
|
/* If we have sessions that needs to be destroyed, do it now */
|
|
|
|
/* If we have sessions that needs to be destroyed, do it now */
|
|
|
|
if (ast_test_flag(&sip->flags[0], SIP_NEEDDESTROY) && !sip->packets &&
|
|
|
|
if (ast_test_flag(&sip->flags[0], SIP_NEEDDESTROY) && !sip->packets &&
|
|
|
|
!sip->owner) {
|
|
|
|
!sip->owner) {
|
|
|
|