X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Ftimeval.c;h=d3b6685e00bb4d8b5f3b375a2f39079fc70c757a;hb=d86a6c099ff4a1e0c7d1b437fa4ff0a9684fcdb9;hp=835b91f7b7270fd8c1644058ed070c182b4088a6;hpb=00a16895875658e14f0c95a5e7d179b70b7c57b5;p=openvswitch diff --git a/lib/timeval.c b/lib/timeval.c index 835b91f7..d3b6685e 100644 --- a/lib/timeval.c +++ b/lib/timeval.c @@ -40,7 +40,7 @@ VLOG_DEFINE_THIS_MODULE(timeval); * to CLOCK_REALTIME. */ static clockid_t monotonic_clock; -/* Has a timer tick occurred? Only relevant if CACHE_TIME is 1. +/* Has a timer tick occurred? Only relevant if CACHE_TIME is true. * * We initialize these to true to force time_init() to get called on the first * call to time_msec() or another function that queries the current time. */ @@ -93,10 +93,8 @@ time_init(void) VLOG_DBG("monotonic timer not available"); } - if (CACHE_TIME) { - set_up_signal(SA_RESTART); - set_up_timer(); - } + set_up_signal(SA_RESTART); + set_up_timer(); boot_time = time_msec(); } @@ -148,6 +146,10 @@ set_up_timer(void) static timer_t timer_id; /* "static" to avoid apparent memory leak. */ struct itimerspec itimer; + if (!CACHE_TIME) { + return; + } + if (timer_create(monotonic_clock, NULL, &timer_id)) { VLOG_FATAL("timer_create failed (%s)", strerror(errno)); } @@ -170,10 +172,7 @@ void time_postfork(void) { time_init(); - - if (CACHE_TIME) { - set_up_timer(); - } + set_up_timer(); } static void @@ -205,7 +204,7 @@ refresh_monotonic(void) /* Forces a refresh of the current time from the kernel. It is not usually * necessary to call this function, since the time will be refreshed * automatically at least every TIME_UPDATE_INTERVAL milliseconds. If - * CACHE_TIME is 0, we will always refresh the current time so this + * CACHE_TIME is false, we will always refresh the current time so this * function has no effect. */ void time_refresh(void)