aboutsummaryrefslogtreecommitdiff
path: root/src/backend/replication
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2010-04-28 16:54:16 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2010-04-28 16:54:16 +0000
commit77acab75dfe2e4741c25c0cf550266caef1eebd2 (patch)
tree1a5d86661c9394e2e79ae038775e874395f24f59 /src/backend/replication
parent5f70a04c56b69fff0f356abae3091eaa54038a5b (diff)
downloadpostgresql-77acab75dfe2e4741c25c0cf550266caef1eebd2.tar.gz
postgresql-77acab75dfe2e4741c25c0cf550266caef1eebd2.zip
Modify ShmemInitStruct and ShmemInitHash to throw errors internally,
rather than returning NULL for some-but-not-all failures as they used to. Remove now-redundant tests for NULL from call sites. We had to do something about this because many call sites were failing to check for NULL; and changing it like this seems a lot more useful and mistake-proof than adding checks to the call sites without them.
Diffstat (limited to 'src/backend/replication')
-rw-r--r--src/backend/replication/walreceiverfuncs.c20
-rw-r--r--src/backend/replication/walsender.c27
2 files changed, 19 insertions, 28 deletions
diff --git a/src/backend/replication/walreceiverfuncs.c b/src/backend/replication/walreceiverfuncs.c
index be305790fd3..78ee7fb9f7e 100644
--- a/src/backend/replication/walreceiverfuncs.c
+++ b/src/backend/replication/walreceiverfuncs.c
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/replication/walreceiverfuncs.c,v 1.4 2010/02/26 02:00:57 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/replication/walreceiverfuncs.c,v 1.5 2010/04/28 16:54:15 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -58,17 +58,13 @@ WalRcvShmemInit(void)
WalRcv = (WalRcvData *)
ShmemInitStruct("Wal Receiver Ctl", WalRcvShmemSize(), &found);
- if (WalRcv == NULL)
- ereport(FATAL,
- (errcode(ERRCODE_OUT_OF_MEMORY),
- errmsg("not enough shared memory for walreceiver")));
- if (found)
- return; /* already initialized */
-
- /* Initialize the data structures */
- MemSet(WalRcv, 0, WalRcvShmemSize());
- WalRcv->walRcvState = WALRCV_STOPPED;
- SpinLockInit(&WalRcv->mutex);
+ if (!found)
+ {
+ /* First time through, so initialize */
+ MemSet(WalRcv, 0, WalRcvShmemSize());
+ WalRcv->walRcvState = WALRCV_STOPPED;
+ SpinLockInit(&WalRcv->mutex);
+ }
}
/* Is walreceiver in progress (or starting up)? */
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 6c41844b5f8..07f2b23c911 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -30,7 +30,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/replication/walsender.c,v 1.18 2010/04/28 16:10:42 heikki Exp $
+ * $PostgreSQL: pgsql/src/backend/replication/walsender.c,v 1.19 2010/04/28 16:54:15 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -268,8 +268,7 @@ WalSndHandshake(void)
if (wal_level == WAL_LEVEL_MINIMAL)
ereport(FATAL,
(errcode(ERRCODE_CANNOT_CONNECT_NOW),
- errmsg("standby connections not allowed because wal_level='minimal'")));
-
+ errmsg("standby connections not allowed because wal_level=\"minimal\"")));
/* Send a CopyOutResponse message, and start streaming */
pq_beginmessage(&buf, 'H');
@@ -838,21 +837,17 @@ WalSndShmemInit(void)
WalSndCtl = (WalSndCtlData *)
ShmemInitStruct("Wal Sender Ctl", WalSndShmemSize(), &found);
- if (WalSndCtl == NULL)
- ereport(FATAL,
- (errcode(ERRCODE_OUT_OF_MEMORY),
- errmsg("not enough shared memory for walsender")));
- if (found)
- return; /* already initialized */
-
- /* Initialize the data structures */
- MemSet(WalSndCtl, 0, WalSndShmemSize());
-
- for (i = 0; i < max_wal_senders; i++)
+ if (!found)
{
- WalSnd *walsnd = &WalSndCtl->walsnds[i];
+ /* First time through, so initialize */
+ MemSet(WalSndCtl, 0, WalSndShmemSize());
+
+ for (i = 0; i < max_wal_senders; i++)
+ {
+ WalSnd *walsnd = &WalSndCtl->walsnds[i];
- SpinLockInit(&walsnd->mutex);
+ SpinLockInit(&walsnd->mutex);
+ }
}
}