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

Commit8528e3d

Browse files
committed
Fix failure to check for open() or fsync() failures.
While it seems OK to not be concerned about fsync() failure for apre-existing signal file, it's not OK to not even check for open()failure. This at least causes complaints from static analyzers,and I think on some platforms passing -1 to fsync() or close() mighttrigger assertion-type failures. Also add (void) casts to make clearthat we're ignoring fsync's result intentionally.Oversights in commit2dedf4d, noted by Coverity.
1 parente9fcfed commit8528e3d

File tree

1 file changed

+12
-5
lines changed
  • src/backend/access/transam

1 file changed

+12
-5
lines changed

‎src/backend/access/transam/xlog.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5327,7 +5327,8 @@ readRecoverySignalFile(void)
53275327

53285328
/*
53295329
* Check for recovery signal files and if found, fsync them since they
5330-
* represent server state information.
5330+
* represent server state information. We don't sweat too much about the
5331+
* possibility of fsync failure, however.
53315332
*
53325333
* If present, standby signal file takes precedence. If neither is present
53335334
* then we won't enter archive recovery.
@@ -5338,8 +5339,11 @@ readRecoverySignalFile(void)
53385339

53395340
fd=BasicOpenFilePerm(STANDBY_SIGNAL_FILE,O_RDWR |PG_BINARY |get_sync_bit(sync_method),
53405341
S_IRUSR |S_IWUSR);
5341-
pg_fsync(fd);
5342-
close(fd);
5342+
if (fd >=0)
5343+
{
5344+
(void)pg_fsync(fd);
5345+
close(fd);
5346+
}
53435347
standby_signal_file_found= true;
53445348
}
53455349
elseif (stat(RECOVERY_SIGNAL_FILE,&stat_buf)==0)
@@ -5348,8 +5352,11 @@ readRecoverySignalFile(void)
53485352

53495353
fd=BasicOpenFilePerm(RECOVERY_SIGNAL_FILE,O_RDWR |PG_BINARY |get_sync_bit(sync_method),
53505354
S_IRUSR |S_IWUSR);
5351-
pg_fsync(fd);
5352-
close(fd);
5355+
if (fd >=0)
5356+
{
5357+
(void)pg_fsync(fd);
5358+
close(fd);
5359+
}
53535360
recovery_signal_file_found= true;
53545361
}
53555362

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp