git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 86bc2d9)
Don't go into infinite loop if /home/postgres/testversion/data directory is not writable.
Tue, 3 Jul 2001 16:49:48 +0000 (16:49 +0000)
Tue, 3 Jul 2001 16:49:48 +0000 (16:49 +0000)

diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c
index 4f2b940b7eaa4f84626c3175371d5ecd2e25d11a..44e6f7681525a1e2870b42fdcad325eb8bff2291 100644 (file)
--- a/src/backend/utils/init/miscinit.c
+++ b/src/backend/utils/init/miscinit.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.72 2001年06月20日 18:07:56 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.73 2001年07月03日 16:49:48 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -539,15 +539,18 @@ CreateLockFile(const char *filename, bool amPostmaster,
{
int fd;
char buffer[MAXPGPATH + 100];
+ int ntries;
int len;
int encoded_pid;
pid_t other_pid;
pid_t my_pid = getpid();
/*
- * We need a loop here because of race conditions.
+ * We need a loop here because of race conditions. But don't loop
+ * forever (for example, a non-writable $PGDATA directory might cause
+ * a failure that won't go away). 100 tries seems like plenty.
*/
- for (;;)
+ for (ntries = 0; ; ntries++)
{
/*
@@ -560,7 +563,7 @@ CreateLockFile(const char *filename, bool amPostmaster,
/*
* Couldn't create the pid file. Probably it already exists.
*/
- if (errno != EEXIST && errno != EACCES)
+ if ((errno != EEXIST && errno != EACCES) || ntries > 100)
elog(FATAL, "Can't create lock file %s: %m", filename);
/*
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /