mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-02 10:22:46 +00:00
Simplified pri_dchannel() poll timeout duration code.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@284780 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -4176,36 +4176,36 @@ static void *pri_dchannel(void *vpri)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Start with reasonable max */
|
/* Start with reasonable max */
|
||||||
lowest = ast_tv(60, 0);
|
if (doidling || pri->resetting) {
|
||||||
|
/*
|
||||||
|
* Make sure we stop at least once per second if we're
|
||||||
|
* monitoring idle channels
|
||||||
|
*/
|
||||||
|
lowest = ast_tv(1, 0);
|
||||||
|
} else {
|
||||||
|
/* Don't poll for more than 60 seconds */
|
||||||
|
lowest = ast_tv(60, 0);
|
||||||
|
}
|
||||||
for (i = 0; i < SIG_PRI_NUM_DCHANS; i++) {
|
for (i = 0; i < SIG_PRI_NUM_DCHANS; i++) {
|
||||||
/* Find lowest available d-channel */
|
if (!pri->dchans[i]) {
|
||||||
if (!pri->dchans[i])
|
/* We scanned all D channels on this span. */
|
||||||
break;
|
break;
|
||||||
if ((next = pri_schedule_next(pri->dchans[i]))) {
|
}
|
||||||
|
next = pri_schedule_next(pri->dchans[i]);
|
||||||
|
if (next) {
|
||||||
/* We need relative time here */
|
/* We need relative time here */
|
||||||
tv = ast_tvsub(*next, ast_tvnow());
|
tv = ast_tvsub(*next, ast_tvnow());
|
||||||
if (tv.tv_sec < 0) {
|
if (tv.tv_sec < 0) {
|
||||||
tv = ast_tv(0,0);
|
/*
|
||||||
|
* A timer has already expired.
|
||||||
|
* By definition zero time is the lowest so we can quit early.
|
||||||
|
*/
|
||||||
|
lowest = ast_tv(0, 0);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (doidling || pri->resetting) {
|
if (ast_tvcmp(tv, lowest) < 0) {
|
||||||
if (tv.tv_sec > 1) {
|
lowest = tv;
|
||||||
tv = ast_tv(1, 0);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (tv.tv_sec > 60) {
|
|
||||||
tv = ast_tv(60, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (doidling || pri->resetting) {
|
|
||||||
/* Make sure we stop at least once per second if we're
|
|
||||||
monitoring idle channels */
|
|
||||||
tv = ast_tv(1,0);
|
|
||||||
} else {
|
|
||||||
/* Don't poll for more than 60 seconds */
|
|
||||||
tv = ast_tv(60, 0);
|
|
||||||
}
|
|
||||||
if (!i || ast_tvcmp(tv, lowest) < 0) {
|
|
||||||
lowest = tv;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast_mutex_unlock(&pri->lock);
|
ast_mutex_unlock(&pri->lock);
|
||||||
|
Reference in New Issue
Block a user