pgsql: Reserve zero as an invalid DSM handle.

From: Robert Haas <rhaas(at)postgresql(dot)org>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Reserve zero as an invalid DSM handle.
Date: 2016-11-15 21:36:03
Message-ID: E1c6lOd-0004Zv-Du@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Reserve zero as an invalid DSM handle.

Previously, the handle for the control segment could not be zero, but
some other DSM segment could potentially have a handle value of zero.
However, that means that if someone wanted to store a dsm_handle that
might or might not be valid, they would need a separate boolean to
keep track of whether the associated value is legal. That's annoying,
so change things so that no DSM segment can ever have a handle of 0 -
or as we call it here, DSM_HANDLE_INVALID.

Thomas Munro. This was submitted as part of a much larger patch to
add an malloc-like allocator for dynamic shared memory, but this part
seems like a good idea independently of the rest of the patch.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/b40b4dd9e10ea701c8d47ccba9407fc32ed384e5

Modified Files
--------------
src/backend/storage/ipc/dsm.c | 4 +++-
src/include/storage/dsm.h | 3 +++
2 files changed, 6 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2016-11-15 21:48:35 pgsql: Check that result tupdesc has exactly 1 column in return_next sc
Previous Message Tom Lane 2016-11-15 21:17:43 pgsql: Allow DOS-style line endings in ~/.pgpass files.