summaryrefslogtreecommitdiff
path: root/src/include/miscadmin.h
diff options
context:
space:
mode:
authorHeikki Linnakangas2024-07-29 12:37:48 +0000
committerHeikki Linnakangas2024-07-29 12:37:48 +0000
commit9d9b9d46f3c509c722ebbf2a1e7dc6296a6c711d (patch)
tree450cf30fdaca9dd1b5336179f2bb590e397fb9f0 /src/include/miscadmin.h
parent19de089cdc23373e2f36916017a1e23e8ff4c2f8 (diff)
Move cancel key generation to after forking the backend
Move responsibility of generating the cancel key to the backend process. The cancel key is now generated after forking, and the backend advertises it in the ProcSignal array. When a cancel request arrives, the backend handling it scans the ProcSignal array to find the target pid and cancel key. This is similar to how this previously worked in the EXEC_BACKEND case with the ShmemBackendArray, just reusing the ProcSignal array. One notable change is that we no longer generate cancellation keys for non-backend processes. We generated them before just to prevent a malicious user from canceling them; the keys for non-backend processes were never actually given to anyone. There is now an explicit flag indicating whether a process has a valid key or not. I wrote this originally in preparation for supporting longer cancel keys, but it's a nice cleanup on its own. Reviewed-by: Jelte Fennema-Nio Discussion: https://www.postgresql.org/message-id/508d0505-8b7a-4864-a681-e7e5edfe32aa@iki.fi
Diffstat (limited to 'src/include/miscadmin.h')
-rw-r--r--src/include/miscadmin.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 90f9b21b258..ac16233b71f 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -191,6 +191,7 @@ extern PGDLLIMPORT pg_time_t MyStartTime;
extern PGDLLIMPORT TimestampTz MyStartTimestamp;
extern PGDLLIMPORT struct Port *MyProcPort;
extern PGDLLIMPORT struct Latch *MyLatch;
+extern PGDLLIMPORT bool MyCancelKeyValid;
extern PGDLLIMPORT int32 MyCancelKey;
extern PGDLLIMPORT int MyPMChildSlot;