Skip to content

Commit 94f5246

Browse files
committed
Fix uninitialized-variable bug.
For some reason, neither of the compilers I usually use noticed the uninitialized-variable problem I introduced in commit 7e2a18a. That's hardly a good enough excuse though. Committing with brown paper bag on head. In addition to putting the operations in the right order, move the declaration of "now" inside the loop; there's no need for it to be outside, and that does wake up older gcc enough to notice any similar future problem. Back-patch to 9.4; earlier versions lack the time-to-SIGKILL stanza so there's no bug.
1 parent 41562b1 commit 94f5246

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/backend/postmaster/postmaster.c

+12-11
Original file line numberDiff line numberDiff line change
@@ -1601,8 +1601,7 @@ ServerLoop(void)
16011601
{
16021602
fd_set readmask;
16031603
int nSockets;
1604-
time_t now,
1605-
last_lockfile_recheck_time,
1604+
time_t last_lockfile_recheck_time,
16061605
last_touch_time;
16071606

16081607
last_lockfile_recheck_time = last_touch_time = time(NULL);
@@ -1613,6 +1612,7 @@ ServerLoop(void)
16131612
{
16141613
fd_set rmask;
16151614
int selres;
1615+
time_t now;
16161616

16171617
/*
16181618
* Wait for a connection request to arrive.
@@ -1764,6 +1764,16 @@ ServerLoop(void)
17641764
Assert(pthread_is_threaded_np() == 0);
17651765
#endif
17661766

1767+
/*
1768+
* Lastly, check to see if it's time to do some things that we don't
1769+
* want to do every single time through the loop, because they're a
1770+
* bit expensive. Note that there's up to a minute of slop in when
1771+
* these tasks will be performed, since DetermineSleepTime() will let
1772+
* us sleep at most that long; except for SIGKILL timeout which has
1773+
* special-case logic there.
1774+
*/
1775+
now = time(NULL);
1776+
17671777
/*
17681778
* If we already sent SIGQUIT to children and they are slow to shut
17691779
* down, it's time to send them SIGKILL. This doesn't happen
@@ -1782,15 +1792,6 @@ ServerLoop(void)
17821792
AbortStartTime = 0;
17831793
}
17841794

1785-
/*
1786-
* Lastly, check to see if it's time to do some things that we don't
1787-
* want to do every single time through the loop, because they're a
1788-
* bit expensive. Note that there's up to a minute of slop in when
1789-
* these tasks will be performed, since DetermineSleepTime() will let
1790-
* us sleep at most that long.
1791-
*/
1792-
now = time(NULL);
1793-
17941795
/*
17951796
* Once a minute, verify that postmaster.pid hasn't been removed or
17961797
* overwritten. If it has, we force a shutdown. This avoids having

0 commit comments

Comments
 (0)