mirror of
https://github.com/postgres/postgres.git
synced 2025-08-28 18:48:04 +03:00
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.
This commit is contained in:
@@ -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)? */
|
||||
|
Reference in New Issue
Block a user