use one gettimeofday call instead of time and gettimeofday
authorAlexey Chernobaev <achernobaev@dev.rtsoft.ru>
Thu, 16 Aug 2018 15:33:52 +0000 (18:33 +0300)
committerAleksei Vereshchagin <avereschagin@dev.rtsoft.ru>
Tue, 28 Aug 2018 22:24:18 +0000 (01:24 +0300)
profctl.c

index 1c2e850d44d79b26f4998b7e1b3b4511761c5d4e..8e6bbdcd3307e8a8a3f3d56c96707f3457d4e45f 100644 (file)
--- a/profctl.c
+++ b/profctl.c
@@ -205,9 +205,13 @@ static void *outstat(void *arg)
 
                struct timeval timeval;
                int err, millisec;
-               time_t t = time(NULL);
+               time_t t;
                err = gettimeofday(&timeval, NULL);
-               if (err != 0) {
+               if (err == 0) {
+                       t = timeval.tv_sec;
+               }
+               else {
+                       t = time(NULL);
                        timeval.tv_usec = 0;
                        timeoutMicrosec = 1000000; // 1 sec
                }