memset(LogicalRepCtx, 0, ApplyLauncherShmemSize());
- LogicalRepCtx->last_start_dsa = DSM_HANDLE_INVALID;
- LogicalRepCtx->last_start_dsh = DSM_HANDLE_INVALID;
+ LogicalRepCtx->last_start_dsa = DSA_HANDLE_INVALID;
+ LogicalRepCtx->last_start_dsh = DSHASH_HANDLE_INVALID;
/* Initialize memory and spin locks for each worker slot. */
for (slot = 0; slot < max_logical_replication_workers; slot++)
MemoryContext oldcontext;
/* Quick exit if we already did this. */
- if (LogicalRepCtx->last_start_dsh != DSM_HANDLE_INVALID &&
+ if (LogicalRepCtx->last_start_dsh != DSHASH_HANDLE_INVALID &&
last_start_times != NULL)
return;
/* Be sure any local memory allocated by DSA routines is persistent. */
oldcontext = MemoryContextSwitchTo(TopMemoryContext);
- if (LogicalRepCtx->last_start_dsh == DSM_HANDLE_INVALID)
+ if (LogicalRepCtx->last_start_dsh == DSHASH_HANDLE_INVALID)
{
/* Initialize dynamic shared hash table for last-start times. */
last_start_times_dsa = dsa_create(LWTRANCHE_LAUNCHER_DSA);
/*
* Loop until we find an unused identifier for the new control segment. We
- * sometimes use 0 as a sentinel value indicating that no control segment
- * is known to exist, so avoid using that value for a real control
- * segment.
+ * sometimes use DSM_HANDLE_INVALID as a sentinel value indicating "no
+ * control segment", so avoid generating that value for a real handle.
*/
for (;;)
{
dsa_handle
dsa_get_handle(dsa_area *area)
{
- Assert(area->control->handle != DSM_HANDLE_INVALID);
+ Assert(area->control->handle != DSA_HANDLE_INVALID);
return area->control->handle;
}
{
dsa_area *area;
- area = attach_internal(place, NULL, DSM_HANDLE_INVALID);
+ area = attach_internal(place, NULL, DSA_HANDLE_INVALID);
/*
* Clean up when the control segment detaches, if a containing DSM segment
/* A handle for a dshash_table which can be shared with other processes. */
typedef dsa_pointer dshash_table_handle;
+/* Sentinel value to use for invalid dshash_table handles. */
+#define DSHASH_HANDLE_INVALID ((dshash_table_handle) InvalidDsaPointer)
+
/* The type for hash values. */
typedef uint32 dshash_hash;
#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);
/* A "name" for a dynamic shared memory segment. */
typedef uint32 dsm_handle;
+/* Sentinel value to use for invalid DSM handles. */
+#define DSM_HANDLE_INVALID ((dsm_handle) 0)
+
/* All the shared-memory operations we know about. */
typedef enum
{
*/
typedef dsm_handle dsa_handle;
+/* Sentinel value to use for invalid dsa_handles. */
+#define DSA_HANDLE_INVALID ((dsa_handle) DSM_HANDLE_INVALID)
+
+
extern dsa_area *dsa_create(int tranche_id);
extern dsa_area *dsa_create_in_place(void *place, size_t size,
int tranche_id, dsm_segment *segment);