Skip to content

Commit 93f9958

Browse files
author
Rachel Heaton
authored
Minor: Remove duplication add error handling (#871)
* Remove duplicate key in docker-compose.yml * Handle non-standard field d_type for stat struct
1 parent 4084ea4 commit 93f9958

2 files changed

Lines changed: 22 additions & 7 deletions

File tree

docker-compose.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ services:
2626
- 5432
2727
node2:
2828
image: citusdata/pg_auto_failover:demo
29-
expose:
30-
- 5432
3129
environment:
3230
PGDATA: /tmp/pgaf
3331
PG_AUTOCTL_DEBUG: 1

src/bin/pg_autoctl/pgctl.c

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,11 +1666,6 @@ pg_log_startup(const char *pgdata, int logLevel)
16661666
char pgLogFilePath[MAXPGPATH] = { 0 };
16671667
struct stat pgLogFileStat;
16681668

1669-
/* our logFiles are regular files, skip . and .. and others */
1670-
if (logFileDirEntry->d_type != DT_REG)
1671-
{
1672-
continue;
1673-
}
16741669

16751670
/* build the absolute file path for the logfile */
16761671
join_path_components(pgLogFilePath,
@@ -1684,6 +1679,28 @@ pg_log_startup(const char *pgdata, int logLevel)
16841679
pgLogFilePath);
16851680
return false;
16861681
}
1682+
1683+
/*
1684+
* our logFiles are regular files, skip . and .. and others
1685+
* first, check for systems that do not handle d_type, and skip non-regular types
1686+
*/
1687+
if (logFileDirEntry->d_type == DT_UNKNOWN)
1688+
{
1689+
if (!S_ISREG(pgLogFileStat.st_mode))
1690+
{
1691+
continue;
1692+
}
1693+
}
1694+
1695+
/*
1696+
* next, ignore all other non-regular types
1697+
* (if this check were first, we would skip all with DT_UNKNOWN)
1698+
*/
1699+
else if (logFileDirEntry->d_type != DT_REG)
1700+
{
1701+
continue;
1702+
}
1703+
16871704
int64_t pgLogFileMtime = ST_MTIME_S(pgLogFileStat);
16881705

16891706
/*

0 commit comments

Comments
 (0)