Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc8fe66d

Browse files
committed
Don't go into infinite loop if /home/postgres/testversion/data directory is not writable.
1 parent86bc2d9 commitc8fe66d

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
intfd;
541541
charbuffer[MAXPGPATH+100];
542+
intntries;
542543
intlen;
543544
intencoded_pid;
544545
pid_tother_pid;
545546
pid_tmy_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)

[8]ページ先頭

©2009-2025 Movatter.jp