Skip to content

Commit c8fe66d

Browse files
committed
Don't go into infinite loop if /home/postgres/testversion/data directory is not writable.
1 parent 86bc2d9 commit c8fe66d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/backend/utils/init/miscinit.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.72 2001/06/20 18:07:56 petere Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.73 2001/07/03 16:49:48 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -539,15 +539,18 @@ CreateLockFile(const char *filename, bool amPostmaster,
539539
{
540540
int fd;
541541
char buffer[MAXPGPATH + 100];
542+
int ntries;
542543
int len;
543544
int encoded_pid;
544545
pid_t other_pid;
545546
pid_t my_pid = getpid();
546547

547548
/*
548-
* We need a loop here because of race conditions.
549+
* We need a loop here because of race conditions. But don't loop
550+
* forever (for example, a non-writable $PGDATA directory might cause
551+
* a failure that won't go away). 100 tries seems like plenty.
549552
*/
550-
for (;;)
553+
for (ntries = 0; ; ntries++)
551554
{
552555

553556
/*
@@ -560,7 +563,7 @@ CreateLockFile(const char *filename, bool amPostmaster,
560563
/*
561564
* Couldn't create the pid file. Probably it already exists.
562565
*/
563-
if (errno != EEXIST && errno != EACCES)
566+
if ((errno != EEXIST && errno != EACCES) || ntries > 100)
564567
elog(FATAL, "Can't create lock file %s: %m", filename);
565568

566569
/*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy