tMake ringing delay checks simpler - ratox - FIFO based tox client
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit d81013a3063e918ba30bf83e6255619ba2b108c0
 (DIR) parent 305dda72d9daaa7bd7324e53a78fe6b999d373a4
 (HTM) Author: z3bra <contactatz3bradotorg>
       Date:   Fri, 25 Nov 2016 18:09:09 +0100
       
       Make ringing delay checks simpler
       
       Diffstat:
         M ratox.c                             |       9 ++++-----
       
       1 file changed, 4 insertions(+), 5 deletions(-)
       ---
 (DIR) diff --git a/ratox.c b/ratox.c
       t@@ -1551,9 +1551,8 @@ loop(void)
                struct friend *f, *ftmp;
                struct request *req, *rtmp;
                struct timeval tv;
       -        struct timespec callstart, now;
                fd_set rfds;
       -        time_t t0, t1;
       +        time_t t0, t1, c0, c1;
                size_t i;
                int    connected = 0, n, r, fd, fdmax;
                char   tstamp[64], c;
       t@@ -1681,8 +1680,8 @@ loop(void)
        
                                if (f->av.state & RINGING) {
                                        if (f->av.state & OUTGOING) {
       -                                        clock_gettime(CLOCK_MONOTONIC, &now);
       -                                        if (now.tv_sec - callstart.tv_sec > RINGINGDELAY)
       +                                        c1 = time(NULL);
       +                                        if (c1 > c0 + RINGINGDELAY)
                                                        cancelcall(f, "Timeout");
                                        }
                                        if (!(f->av.state & INCOMING))
       t@@ -1767,7 +1766,7 @@ loop(void)
                                                        fiforeset(f->dirfd, &f->fd[FCALL_IN], ffiles[FCALL_IN]);
                                                        break;
                                                }
       -                                        clock_gettime(CLOCK_MONOTONIC, &callstart);
       +                                        c0 = time(NULL);
                                                f->av.n = 0;
                                                f->av.lastsent.tv_sec = 0;
                                                f->av.lastsent.tv_nsec = 0;