On Tue, Apr 18, 2017 at 03:48:12PM +0200, Willy Tarreau wrote:
> > I am don't know how to add loging to ev_kqueue.c for print
> > now_ms/exp/other stuff.
> 
> Just after assignment of timeout.tv_sec/nsec, you could do something
> like this :
> 
>   if (timeout.tv_sec < 0 || timeout.tv_nsec < 0 || timeout.tv_nsec >= 
> 1000000000)
>      fprintf(stderr, "sec=%u nsec=%u\n", (unsigned)timeout.tv_sec, 
> (unsigned)timeout.tv_nsec);
> 
> There's also fddebug() to emit this output on fd -1 so that it can be
> debugged with strace/truss instead of polluting the stderr.

By the way feel free to use the attached patch to force the date to wrap
5s after boot, we've used it to try to reproduce the issue in vain :-/

Willy
>From aefa4214292a08d0b91dfab57213c971e0f1ce00 Mon Sep 17 00:00:00 2001
From: Willy Tarreau <w...@1wt.eu>
Date: Mon, 13 Mar 2017 19:59:26 +0100
Subject: WIP/DEBUG: force date to wrap at -5 seconds

---
 src/time.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/time.c b/src/time.c
index 6118762..4f3c03b 100644
--- a/src/time.c
+++ b/src/time.c
@@ -168,8 +168,11 @@ REGPRM2 void tv_update_date(int max_wait, int interrupted)
 
        gettimeofday(&date, NULL);
        if (unlikely(max_wait < 0)) {
+               //tv_zero(&tv_offset);
+               //adjusted = date;
                tv_zero(&tv_offset);
-               adjusted = date;
+               tv_offset.tv_sec = 4294962 - date.tv_sec; // -5 seconds
+               __tv_add(&adjusted, &date, &tv_offset);
                after_poll = date;
                samp_time = idle_time = 0;
                idle_pct = 100;
@@ -215,6 +218,7 @@ REGPRM2 void tv_update_date(int max_wait, int interrupted)
         */
        ms_left_scaled = (999U - curr_sec_ms) * 4294967U;
        now_ms = now.tv_sec * 1000 + curr_sec_ms;
+fddebug("date=%u\n", now_ms);
        return;
 }
 
-- 
1.7.12.1

Reply via email to