summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2016-11-15 16:30:35 -0500
committerRobert Haas <rhaas@postgresql.org>2016-11-15 16:33:29 -0500
commitb40b4dd9e10ea701c8d47ccba9407fc32ed384e5 (patch)
tree97a6bd5f4ba10dcecd8a0f3900c4cbe37be8dbd5 /src/include
parent0a7481930c788e9d74a154aac0c8b401fc6a81f9 (diff)
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.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/storage/dsm.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/include/storage/dsm.h b/src/include/storage/dsm.h
index 8be7c9aeeb5..bc91be62131 100644
--- a/src/include/storage/dsm.h
+++ b/src/include/storage/dsm.h
@@ -19,6 +19,9 @@ typedef struct dsm_segment dsm_segment;
#define DSM_CREATE_NULL_IF_MAXSEGMENTS 0x0001
+/* A sentinel value for an invalid DSM handle. */
+#define DSM_HANDLE_INVALID 0
+
/* Startup and shutdown functions. */
struct PGShmemHeader; /* avoid including pg_shmem.h */
extern void dsm_cleanup_using_control_segment(dsm_handle old_control_handle);