diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2002-10-03 19:17:55 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2002-10-03 19:17:55 +0000 |
commit | edf497dec96e7c69618c3654ecb7769342906f1c (patch) | |
tree | 403a5859ea7dd50fe727a8a1cf07d98123421c38 /src | |
parent | 9886a46e76eed65d331c6bc250680249c4748a6c (diff) | |
download | postgresql-edf497dec96e7c69618c3654ecb7769342906f1c.tar.gz postgresql-edf497dec96e7c69618c3654ecb7769342906f1c.zip |
Avoid palloc(0) when MaxBackends = 1.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/storage/lmgr/deadlock.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/backend/storage/lmgr/deadlock.c b/src/backend/storage/lmgr/deadlock.c index 155b1a42ea6..ca892b2cc0a 100644 --- a/src/backend/storage/lmgr/deadlock.c +++ b/src/backend/storage/lmgr/deadlock.c @@ -12,7 +12,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/deadlock.c,v 1.13 2002/09/04 20:31:25 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/deadlock.c,v 1.14 2002/10/03 19:17:55 tgl Exp $ * * Interface: * @@ -125,9 +125,11 @@ InitDeadLockChecking(void) * We need to consider rearranging at most MaxBackends/2 wait queues * (since it takes at least two waiters in a queue to create a soft * edge), and the expanded form of the wait queues can't involve more - * than MaxBackends total waiters. + * than MaxBackends total waiters. (But avoid palloc(0) if + * MaxBackends = 1.) */ - waitOrders = (WAIT_ORDER *) palloc((MaxBackends / 2) * sizeof(WAIT_ORDER)); + waitOrders = (WAIT_ORDER *) + palloc(((MaxBackends + 1) / 2) * sizeof(WAIT_ORDER)); waitOrderProcs = (PGPROC **) palloc(MaxBackends * sizeof(PGPROC *)); /* |