]> granicus.if.org Git - postgresql/commitdiff
Fix unportable coding in DetermineSleepTime().
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 15 Feb 2014 22:09:50 +0000 (17:09 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 15 Feb 2014 22:09:50 +0000 (17:09 -0500)
We should not assume that struct timeval.tv_sec is a long, because
it ain't necessarily.  (POSIX says that it's a time_t, which might
well be 64 bits now or in the future; or for that matter might be
32 bits on machines with 64-bit longs.)  Per buildfarm member panther.

Back-patch to 9.3 where the dubious coding was introduced.

src/backend/postmaster/postmaster.c

index 6bb2a474857ce070a96b8c6e9deb5e36fb2e076e..b7f99fc18d3128eccd7d671d0a5927d124615510 100644 (file)
@@ -1462,10 +1462,12 @@ DetermineSleepTime(struct timeval * timeout)
 
        if (next_wakeup != 0)
        {
+               long            secs;
                int                     microsecs;
 
                TimestampDifference(GetCurrentTimestamp(), next_wakeup,
-                                                       &timeout->tv_sec, &microsecs);
+                                                       &secs, &microsecs);
+               timeout->tv_sec = secs;
                timeout->tv_usec = microsecs;
 
                /* Ensure we don't exceed one minute */