Skip to content

Commit

Permalink
Minor: Remove duplication add error handling (#871)
Browse files Browse the repository at this point in the history
* Remove duplicate key in docker-compose.yml
* Handle non-standard field d_type for stat struct
  • Loading branch information
Rachel Heaton committed Jan 27, 2022
1 parent 4084ea4 commit 93f9958
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ services:
- 5432
node2:
image: citusdata/pg_auto_failover:demo
expose:
- 5432
environment:
PGDATA: /tmp/pgaf
PG_AUTOCTL_DEBUG: 1
Expand Down
27 changes: 22 additions & 5 deletions src/bin/pg_autoctl/pgctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1666,11 +1666,6 @@ pg_log_startup(const char *pgdata, int logLevel)
char pgLogFilePath[MAXPGPATH] = { 0 };
struct stat pgLogFileStat;

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

/* build the absolute file path for the logfile */
join_path_components(pgLogFilePath,
Expand All @@ -1684,6 +1679,28 @@ pg_log_startup(const char *pgdata, int logLevel)
pgLogFilePath);
return false;
}

/*
* our logFiles are regular files, skip . and .. and others
* first, check for systems that do not handle d_type, and skip non-regular types
*/
if (logFileDirEntry->d_type == DT_UNKNOWN)
{
if (!S_ISREG(pgLogFileStat.st_mode))
{
continue;
}
}

/*
* next, ignore all other non-regular types
* (if this check were first, we would skip all with DT_UNKNOWN)
*/
else if (logFileDirEntry->d_type != DT_REG)
{
continue;
}

int64_t pgLogFileMtime = ST_MTIME_S(pgLogFileStat);

/*
Expand Down

0 comments on commit 93f9958

Please sign in to comment.