Add sched_when function (bug #4022)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5466 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.2-netsec
Mark Spencer 20 years ago
parent 42da18ec5f
commit 8d1744dd29

@ -6666,7 +6666,7 @@ static int _sip_show_peer(int type, int fd, struct mansession *s, struct message
ast_cli(fd, "Outgoinglimit: %d\r\n", peer->outgoinglimit); ast_cli(fd, "Outgoinglimit: %d\r\n", peer->outgoinglimit);
ast_cli(fd, "Dynamic: %s\r\n", (ast_test_flag(peer, SIP_DYNAMIC)?"Y":"N")); ast_cli(fd, "Dynamic: %s\r\n", (ast_test_flag(peer, SIP_DYNAMIC)?"Y":"N"));
ast_cli(fd, "Callerid: %s\r\n", ast_callerid_merge(cbuf, sizeof(cbuf), peer->cid_name, peer->cid_num, "")); ast_cli(fd, "Callerid: %s\r\n", ast_callerid_merge(cbuf, sizeof(cbuf), peer->cid_name, peer->cid_num, ""));
ast_cli(fd, "RegExpire: %d\r\n", peer->expire); ast_cli(fd, "RegExpire: %ld seconds\r\n", ast_sched_when(sched,peer->expire));
ast_cli(fd, "RegExpiry: %d\r\n", peer->expiry); ast_cli(fd, "RegExpiry: %d\r\n", peer->expiry);
ast_cli(fd, "SIP-AuthInsecure: %s\r\n", insecure2str(ast_test_flag(peer, SIP_INSECURE))); ast_cli(fd, "SIP-AuthInsecure: %s\r\n", insecure2str(ast_test_flag(peer, SIP_INSECURE)));
ast_cli(fd, "SIP-NatSupport: %s\r\n", nat2str(ast_test_flag(peer, SIP_NAT))); ast_cli(fd, "SIP-NatSupport: %s\r\n", nat2str(ast_test_flag(peer, SIP_NAT)));

@ -102,6 +102,13 @@ extern int ast_sched_runq(struct sched_context *con);
*/ */
extern void ast_sched_dump(struct sched_context *con); extern void ast_sched_dump(struct sched_context *con);
/*!Returns the number of seconds before an event takes place */
/*!
* \param con Context to use
* \param id Id to dump
*/
extern long ast_sched_when(struct sched_context *con,int id);
/* /*
*! Convenience macro for objects and reference (add) *! Convenience macro for objects and reference (add)
* *

@ -399,3 +399,28 @@ int ast_sched_runq(struct sched_context *con)
ast_mutex_unlock(&con->lock); ast_mutex_unlock(&con->lock);
return x; return x;
} }
long ast_sched_when(struct sched_context *con,int id)
{
struct sched *s;
long secs;
struct timeval now;
DEBUG(ast_log(LOG_DEBUG, "ast_sched_when()\n"));
ast_mutex_lock(&con->lock);
s=con->schedq;
while (s!=NULL) {
if (s->id==id) break;
s=s->next;
}
secs=-1;
if (s!=NULL) {
if (gettimeofday(&now, NULL)) {
ast_log(LOG_NOTICE, "gettimeofday() failed!\n");
} else {
secs=s->when.tv_sec-now.tv_sec;
}
}
ast_mutex_unlock(&con->lock);
return secs;
}

Loading…
Cancel
Save