]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Check gettimeofday() failures
authorTimo Sirainen <tss@iki.fi>
Wed, 19 Feb 2003 21:24:05 +0000 (23:24 +0200)
committerTimo Sirainen <tss@iki.fi>
Wed, 19 Feb 2003 21:24:05 +0000 (23:24 +0200)
--HG--
branch : HEAD

src/lib/ioloop.c

index 9526726e277b5ed2b694f5d6726adf1ab0a79076..e8a10cbd88be7624a58fb2eb830effb4441652a5 100644 (file)
@@ -162,9 +162,10 @@ static void timeout_list_insert(struct ioloop *ioloop, struct timeout *timeout)
 
 static void timeout_update_next(struct timeout *timeout, struct timeval *tv_now)
 {
-        if (tv_now == NULL)
-               gettimeofday(&timeout->next_run, NULL);
-       else {
+       if (tv_now == NULL) {
+               if (gettimeofday(&timeout->next_run, NULL) < 0)
+                       i_fatal("gettimeofday(): %m");
+       } else {
                 timeout->next_run.tv_sec = tv_now->tv_sec;
                 timeout->next_run.tv_usec = tv_now->tv_usec;
        }
@@ -225,9 +226,10 @@ int io_loop_get_wait_time(struct timeout *timeout, struct timeval *tv,
        if (timeout == NULL)
                return INT_MAX;
 
-       if (tv_now == NULL)
-               gettimeofday(tv, NULL);
-       else {
+       if (tv_now == NULL) {
+               if (gettimeofday(tv, NULL) < 0)
+                       i_fatal("gettimeofday(): %m");
+       } else {
                tv->tv_sec = tv_now->tv_sec;
                tv->tv_usec = tv_now->tv_usec;
        }
@@ -254,7 +256,8 @@ void io_loop_handle_timeouts(struct ioloop *ioloop)
        struct timeval tv;
         unsigned int t_id;
 
-       gettimeofday(&ioloop_timeval, &ioloop_timezone);
+       if (gettimeofday(&ioloop_timeval, &ioloop_timezone) < 0)
+               i_fatal("gettimeofday(): %m");
        ioloop_time = ioloop_timeval.tv_sec;
 
        if (ioloop->timeouts == NULL || !ioloop->timeouts->run_now)
@@ -312,7 +315,8 @@ struct ioloop *io_loop_create(pool_t pool)
        struct ioloop *ioloop;
 
        /* initialize time */
-       gettimeofday(&ioloop_timeval, &ioloop_timezone);
+       if (gettimeofday(&ioloop_timeval, &ioloop_timezone) < 0)
+               i_fatal("gettimeofday(): %m");
        ioloop_time = ioloop_timeval.tv_sec;
 
         ioloop = p_new(pool, struct ioloop, 1);