mirror of
https://github.com/postgres/postgres.git
synced 2025-10-25 13:17:41 +03:00
Fix some places that were unportably assuming struct timeval's tv_sec
field is signed. Clean up casting.
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
*
|
||||
* Copyright (c) 2001, PostgreSQL Global Development Group
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/postmaster/pgstat.c,v 1.30 2002/10/21 19:59:14 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/postmaster/pgstat.c,v 1.31 2002/10/24 23:19:13 tgl Exp $
|
||||
* ----------
|
||||
*/
|
||||
#include "postgres.h"
|
||||
@@ -1247,19 +1247,27 @@ pgstat_main(void)
|
||||
*/
|
||||
if (need_statwrite)
|
||||
{
|
||||
gettimeofday(&timeout, NULL);
|
||||
timeout.tv_usec = next_statwrite.tv_usec - timeout.tv_usec;
|
||||
timeout.tv_sec = next_statwrite.tv_sec - timeout.tv_sec;
|
||||
if (timeout.tv_usec < 0)
|
||||
{
|
||||
timeout.tv_sec -= 1;
|
||||
timeout.tv_usec += 1000000;
|
||||
}
|
||||
if (timeout.tv_sec < 0)
|
||||
struct timeval now;
|
||||
|
||||
gettimeofday(&now, NULL);
|
||||
/* avoid assuming that tv_sec is signed */
|
||||
if (now.tv_sec > next_statwrite.tv_sec ||
|
||||
(now.tv_sec == next_statwrite.tv_sec &&
|
||||
now.tv_usec >= next_statwrite.tv_usec))
|
||||
{
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
timeout.tv_sec = next_statwrite.tv_sec - now.tv_sec;
|
||||
timeout.tv_usec = next_statwrite.tv_usec - now.tv_usec;
|
||||
if (timeout.tv_usec < 0)
|
||||
{
|
||||
timeout.tv_sec--;
|
||||
timeout.tv_usec += 1000000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user