mirror of
https://github.com/postgres/postgres.git
synced 2025-04-22 23:02:54 +03:00
Guard against malloc failure. Also, don't examine segP->lastBackend
until we hold the spinlock.
This commit is contained in:
parent
d8adce8983
commit
ddd96e1f21
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.31 2001/05/18 21:24:20 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.32 2001/06/01 20:07:16 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -283,15 +283,24 @@ GetSnapshotData(bool serializable)
|
|||||||
int index;
|
int index;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
|
if (snapshot == NULL)
|
||||||
|
elog(ERROR, "Memory exhausted in GetSnapshotData");
|
||||||
|
|
||||||
|
snapshot->xmin = GetCurrentTransactionId();
|
||||||
|
|
||||||
|
SpinAcquire(SInvalLock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* There can be no more than lastBackend active transactions, so this
|
* There can be no more than lastBackend active transactions, so this
|
||||||
* is enough space:
|
* is enough space:
|
||||||
*/
|
*/
|
||||||
snapshot->xip = (TransactionId *)
|
snapshot->xip = (TransactionId *)
|
||||||
malloc(segP->lastBackend * sizeof(TransactionId));
|
malloc(segP->lastBackend * sizeof(TransactionId));
|
||||||
snapshot->xmin = GetCurrentTransactionId();
|
if (snapshot->xip == NULL)
|
||||||
|
{
|
||||||
SpinAcquire(SInvalLock);
|
SpinRelease(SInvalLock);
|
||||||
|
elog(ERROR, "Memory exhausted in GetSnapshotData");
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Unfortunately, we have to call ReadNewTransactionId() after
|
* Unfortunately, we have to call ReadNewTransactionId() after
|
||||||
|
Loading…
x
Reference in New Issue
Block a user