From 82f8c45be551a2940e3cbaf08aa7a521bdac8331 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Fri, 25 Dec 2020 22:47:16 -0500 Subject: [PATCH] pg_alterckey: adjust doc build and Win32 sleep/open build fails Fix for commit 62afb42a7f. Reported-by: Tom Lane Discussion: https://postgr.es/m/1252111.1608953815@sss.pgh.pa.us Backpatch-through: master --- doc/src/sgml/ref/allfiles.sgml | 3 ++- .../ref/{pg_alterkey.sgml => pg_alterckey.sgml} | 0 src/bin/pg_alterckey/pg_alterckey.c | 13 +++++++------ 3 files changed, 9 insertions(+), 7 deletions(-) rename doc/src/sgml/ref/{pg_alterkey.sgml => pg_alterckey.sgml} (100%) diff --git a/doc/src/sgml/ref/allfiles.sgml b/doc/src/sgml/ref/allfiles.sgml index 0f0064150c4..4e9504e11b6 100644 --- a/doc/src/sgml/ref/allfiles.sgml +++ b/doc/src/sgml/ref/allfiles.sgml @@ -189,6 +189,7 @@ Complete list of usable sgml source files in this directory. + @@ -215,7 +216,7 @@ Complete list of usable sgml source files in this directory. - + diff --git a/doc/src/sgml/ref/pg_alterkey.sgml b/doc/src/sgml/ref/pg_alterckey.sgml similarity index 100% rename from doc/src/sgml/ref/pg_alterkey.sgml rename to doc/src/sgml/ref/pg_alterckey.sgml diff --git a/src/bin/pg_alterckey/pg_alterckey.c b/src/bin/pg_alterckey/pg_alterckey.c index 78b06131654..6c473e33970 100644 --- a/src/bin/pg_alterckey/pg_alterckey.c +++ b/src/bin/pg_alterckey/pg_alterckey.c @@ -343,16 +343,17 @@ create_lockfile(void) unlink(pid_path); /* Sleep to reduce the likelihood of concurrent unlink */ - sleep(2); + pg_usleep(2000000L); /* 2 seconds */ } /* Create our own lockfile? */ - lock_fd = open(pid_path, O_RDWR | O_CREAT | O_EXCL -#ifdef WIN32 - /* delete on close */ - | O_TEMPORARY +#ifndef WIN32 + lock_fd = open(pid_path, O_RDWR | O_CREAT | O_EXCL, pg_file_create_mode); +#else + /* delete on close */ + lock_fd = open(pid_path, O_RDWR | O_CREAT | O_EXCL | O_TEMPORARY, + pg_file_create_mode); #endif - , pg_file_create_mode); if (lock_fd == -1) {