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

Commita11c8be

Browse files
committed
Back-patch fix to prevent infinite loop when $PGDATA is not writable.
1 parent7d03946 commita11c8be

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.65 2001/04/16 02:42:01 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.65.2.1 2001/08/08 22:25:45 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -490,15 +490,18 @@ CreateLockFile(const char *filename, bool amPostmaster,
490490
{
491491
intfd;
492492
charbuffer[MAXPGPATH+100];
493+
intntries;
493494
intlen;
494495
intencoded_pid;
495496
pid_tother_pid;
496497
pid_tmy_pid=getpid();
497498

498499
/*
499-
* We need a loop here because of race conditions.
500+
* We need a loop here because of race conditions. But don't loop
501+
* forever (for example, a non-writable $PGDATA directory might cause
502+
* a failure that won't go away). 100 tries seems like plenty.
500503
*/
501-
for (;;)
504+
for (ntries=0; ;ntries++)
502505
{
503506

504507
/*
@@ -511,7 +514,7 @@ CreateLockFile(const char *filename, bool amPostmaster,
511514
/*
512515
* Couldn't create the pid file. Probably it already exists.
513516
*/
514-
if (errno!=EEXIST&&errno!=EACCES)
517+
if ((errno!=EEXIST&&errno!=EACCES)||ntries>100)
515518
elog(FATAL,"Can't create lock file %s: %m",filename);
516519

517520
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp