Skip to content

Commit edf497d

Browse files
committed
Avoid palloc(0) when MaxBackends = 1.
1 parent 9886a46 commit edf497d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/backend/storage/lmgr/deadlock.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
*
1414
* IDENTIFICATION
15-
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/deadlock.c,v 1.13 2002/09/04 20:31:25 momjian Exp $
15+
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/deadlock.c,v 1.14 2002/10/03 19:17:55 tgl Exp $
1616
*
1717
* Interface:
1818
*
@@ -125,9 +125,11 @@ InitDeadLockChecking(void)
125125
* We need to consider rearranging at most MaxBackends/2 wait queues
126126
* (since it takes at least two waiters in a queue to create a soft
127127
* edge), and the expanded form of the wait queues can't involve more
128-
* than MaxBackends total waiters.
128+
* than MaxBackends total waiters. (But avoid palloc(0) if
129+
* MaxBackends = 1.)
129130
*/
130-
waitOrders = (WAIT_ORDER *) palloc((MaxBackends / 2) * sizeof(WAIT_ORDER));
131+
waitOrders = (WAIT_ORDER *)
132+
palloc(((MaxBackends + 1) / 2) * sizeof(WAIT_ORDER));
131133
waitOrderProcs = (PGPROC **) palloc(MaxBackends * sizeof(PGPROC *));
132134

133135
/*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy