diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2011-08-10 12:20:45 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2011-08-10 12:20:45 -0400 |
commit | 989f530d3f793ed1c990d705d0958bfd2a533b85 (patch) | |
tree | a6676b9e587c9caf40b0e8dfd99bbd6bab4dd35f /src/backend/replication/syncrep.c | |
parent | 74d099494c5853a44188316ba117a8909b299d40 (diff) |
Back-patch assorted latch-related fixes.
Fix a whole bunch of signal handlers that had been hacked to do things that
might change errno, without adding the necessary save/restore logic for
errno. Also make some minor fixes in unix_latch.c, and clean up bizarre
and unsafe scheme for disowning the process's latch. While at it, rename
the PGPROC latch field to procLatch for consistency with 9.2.
Issues noted while reviewing a patch by Peter Geoghegan.
Diffstat (limited to 'src/backend/replication/syncrep.c')
-rw-r--r-- | src/backend/replication/syncrep.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/backend/replication/syncrep.c b/src/backend/replication/syncrep.c index 8713b9700dc..6463420cd85 100644 --- a/src/backend/replication/syncrep.c +++ b/src/backend/replication/syncrep.c @@ -111,9 +111,6 @@ SyncRepWaitForLSN(XLogRecPtr XactCommitLSN) Assert(SHMQueueIsDetached(&(MyProc->syncRepLinks))); Assert(WalSndCtl != NULL); - /* Reset the latch before adding ourselves to the queue. */ - ResetLatch(&MyProc->waitLatch); - LWLockAcquire(SyncRepLock, LW_EXCLUSIVE); Assert(MyProc->syncRepState == SYNC_REP_NOT_WAITING); @@ -167,7 +164,7 @@ SyncRepWaitForLSN(XLogRecPtr XactCommitLSN) int syncRepState; /* Must reset the latch before testing state. */ - ResetLatch(&MyProc->waitLatch); + ResetLatch(&MyProc->procLatch); /* * Try checking the state without the lock first. There's no @@ -247,11 +244,11 @@ SyncRepWaitForLSN(XLogRecPtr XactCommitLSN) } /* - * Wait on latch for up to 60 seconds. This allows us to check for + * Wait on latch for up to 10 seconds. This allows us to check for * cancel/die signal or postmaster death regularly while waiting. Note * that timeout here does not necessarily release from loop. */ - WaitLatch(&MyProc->waitLatch, 60000L); + WaitLatch(&MyProc->procLatch, 10000L); } /* @@ -322,7 +319,7 @@ SyncRepCancelWait(void) } void -SyncRepCleanupAtProcExit(int code, Datum arg) +SyncRepCleanupAtProcExit(void) { if (!SHMQueueIsDetached(&(MyProc->syncRepLinks))) { @@ -330,8 +327,6 @@ SyncRepCleanupAtProcExit(int code, Datum arg) SHMQueueDelete(&(MyProc->syncRepLinks)); LWLockRelease(SyncRepLock); } - - DisownLatch(&MyProc->waitLatch); } /* @@ -560,9 +555,7 @@ SyncRepWakeQueue(bool all) /* * Wake only when we have set state and removed from queue. */ - Assert(SHMQueueIsDetached(&(thisproc->syncRepLinks))); - Assert(thisproc->syncRepState == SYNC_REP_WAIT_COMPLETE); - SetLatch(&(thisproc->waitLatch)); + SetLatch(&(thisproc->procLatch)); numprocs++; } |