]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
create useful output for time left to expire (bug #4022)
authorRussell Bryant <russell@russellbryant.com>
Fri, 15 Apr 2005 07:24:34 +0000 (07:24 +0000)
committerRussell Bryant <russell@russellbryant.com>
Fri, 15 Apr 2005 07:24:34 +0000 (07:24 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/v1-0@5476 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c
include/asterisk/sched.h
sched.c

index c7bcbd95abc7b974a7d3341bed235d783c037d34..67f1e7f70981310cf1d01930425b27bf8378fe73 100755 (executable)
@@ -603,6 +603,7 @@ static int __sip_xmit(struct sip_pvt *p, char *data, int len)
 {
        int res;
        char iabuf[INET_ADDRSTRLEN];
+// ast_log(LOG_WARNING, "__sip_xmit from '%s' to '%s'\n", "", ast_inet_ntoa(iabuf, sizeof(iabuf), p->recv.sin_addr));
        if (p->nat & SIP_NAT_ROUTE)
            res=sendto(sipsock, data, len, 0, (struct sockaddr *)&p->recv, sizeof(struct sockaddr_in));
        else
@@ -5809,7 +5810,7 @@ static int sip_show_peer(int fd, int argc, char *argv[])
                ast_cli(fd, "  Mailbox      : %s\n", peer->mailbox);
                ast_cli(fd, "  LastMsgsSent : %d\n", peer->lastmsgssent);
                ast_cli(fd, "  Dynamic      : %s\n", (peer->dynamic?"Yes":"No"));
-               ast_cli(fd, "  Expire       : %d\n", peer->expire);
+               ast_cli(fd, "  Expire       : %ld seconds\n", ast_sched_when(sched,peer->expire));
                ast_cli(fd, "  Expiry       : %d\n", peer->expiry);
                ast_cli(fd, "  Insecure     : %s\n", (peer->insecure?((peer->insecure == 2)?"Very":"Yes"):"No") );
                ast_cli(fd, "  Nat          : %s\n", nat2str(peer->nat));
index fc8c797b123ccde343677a8709bb0d17e2dada4b..6e43a0c6cbbcd952b037cd6595b0caf14c415b28 100755 (executable)
@@ -102,6 +102,14 @@ extern int ast_sched_runq(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);
+
+
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif
diff --git a/sched.c b/sched.c
index 6dedace568c6729d906ec51b1a0507555d555eb5..e8c2238d8c9bcb67d24c06cb857c4bb573048756 100755 (executable)
--- a/sched.c
+++ b/sched.c
@@ -399,3 +399,28 @@ int ast_sched_runq(struct sched_context *con)
        ast_mutex_unlock(&con->lock);
        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;
+}