Skip to content

Commit 02ca67d

Browse files
committed
Merge branch 'master' into release_2_5
2 parents 6bdd241 + 477e5bc commit 02ca67d

File tree

9 files changed

+185
-129
lines changed

9 files changed

+185
-129
lines changed

src/catalog.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ IsDir(const char *dirpath, const char *entry, fio_location location)
842842
char path[MAXPGPATH];
843843
struct stat st;
844844

845-
snprintf(path, MAXPGPATH, "%s/%s", dirpath, entry);
845+
join_path_components(path, dirpath, entry);
846846

847847
return fio_stat(path, &st, false, location) == 0 && S_ISDIR(st.st_mode);
848848
}
@@ -956,7 +956,7 @@ catalog_get_backup_list(InstanceState *instanceState, time_t requested_backup_id
956956
join_path_components(data_path, instanceState->instance_backup_subdir_path, data_ent->d_name);
957957

958958
/* read backup information from BACKUP_CONTROL_FILE */
959-
snprintf(backup_conf_path, MAXPGPATH, "%s/%s", data_path, BACKUP_CONTROL_FILE);
959+
join_path_components(backup_conf_path, data_path, BACKUP_CONTROL_FILE);
960960
backup = readBackupControlFile(backup_conf_path);
961961

962962
if (!backup)

src/data.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1516,7 +1516,7 @@ validate_one_page(Page page, BlockNumber absolute_blkno,
15161516
}
15171517

15181518
/*
1519-
* Valiate pages of datafile in PGDATA one by one.
1519+
* Validate pages of datafile in PGDATA one by one.
15201520
*
15211521
* returns true if the file is valid
15221522
* also returns true if the file was not found

src/parsexlog.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ SimpleXLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr,
10171017

10181018
GetXLogFileName(xlogfname, reader_data->tli, reader_data->xlogsegno, wal_seg_size);
10191019

1020-
snprintf(reader_data->xlogpath, MAXPGPATH, "%s/%s", wal_archivedir, xlogfname);
1020+
join_path_components(reader_data->xlogpath, wal_archivedir, xlogfname);
10211021
snprintf(reader_data->gz_xlogpath, MAXPGPATH, "%s.gz", reader_data->xlogpath);
10221022

10231023
/* We fall back to using .partial segment in case if we are running

src/pg_probackup.h

-2
Original file line numberDiff line numberDiff line change
@@ -1101,8 +1101,6 @@ extern PageState *get_checksum_map(const char *fullpath, uint32 checksum_version
11011101
int n_blocks, XLogRecPtr dest_stop_lsn, BlockNumber segmentno);
11021102
extern datapagemap_t *get_lsn_map(const char *fullpath, uint32 checksum_version,
11031103
int n_blocks, XLogRecPtr shift_lsn, BlockNumber segmentno);
1104-
extern pid_t check_postmaster(const char *pgdata);
1105-
11061104
extern bool validate_file_pages(pgFile *file, const char *fullpath, XLogRecPtr stop_lsn,
11071105
uint32 checksum_version, uint32 backup_version, HeaderMap *hdr_map);
11081106

src/restore.c

+6-7
Original file line numberDiff line numberDiff line change
@@ -1483,7 +1483,7 @@ update_recovery_options_before_v12(InstanceState *instanceState, pgBackup *backu
14831483
}
14841484

14851485
elog(LOG, "update recovery settings in recovery.conf");
1486-
snprintf(path, lengthof(path), "%s/recovery.conf", instance_config.pgdata);
1486+
join_path_components(path, instance_config.pgdata, "recovery.conf");
14871487

14881488
fp = fio_fopen(path, "w", FIO_DB_HOST);
14891489
if (fp == NULL)
@@ -1540,8 +1540,7 @@ update_recovery_options(InstanceState *instanceState, pgBackup *backup,
15401540

15411541
time2iso(current_time_str, lengthof(current_time_str), current_time, false);
15421542

1543-
snprintf(postgres_auto_path, lengthof(postgres_auto_path),
1544-
"%s/postgresql.auto.conf", instance_config.pgdata);
1543+
join_path_components(postgres_auto_path, instance_config.pgdata, "postgresql.auto.conf");
15451544

15461545
if (fio_stat(postgres_auto_path, &st, false, FIO_DB_HOST) < 0)
15471546
{
@@ -1651,7 +1650,7 @@ update_recovery_options(InstanceState *instanceState, pgBackup *backup,
16511650
if (params->recovery_settings_mode == PITR_REQUESTED)
16521651
{
16531652
elog(LOG, "creating recovery.signal file");
1654-
snprintf(path, lengthof(path), "%s/recovery.signal", instance_config.pgdata);
1653+
join_path_components(path, instance_config.pgdata, "recovery.signal");
16551654

16561655
fp = fio_fopen(path, PG_BINARY_W, FIO_DB_HOST);
16571656
if (fp == NULL)
@@ -1667,7 +1666,7 @@ update_recovery_options(InstanceState *instanceState, pgBackup *backup,
16671666
if (params->restore_as_replica)
16681667
{
16691668
elog(LOG, "creating standby.signal file");
1670-
snprintf(path, lengthof(path), "%s/standby.signal", instance_config.pgdata);
1669+
join_path_components(path, instance_config.pgdata, "standby.signal");
16711670

16721671
fp = fio_fopen(path, PG_BINARY_W, FIO_DB_HOST);
16731672
if (fp == NULL)
@@ -2163,7 +2162,7 @@ check_incremental_compatibility(const char *pgdata, uint64 system_identifier,
21632162
{
21642163
char pid_file[MAXPGPATH];
21652164

2166-
snprintf(pid_file, MAXPGPATH, "%s/postmaster.pid", pgdata);
2165+
join_path_components(pid_file, pgdata, "postmaster.pid");
21672166
elog(WARNING, "Pid file \"%s\" is mangled, cannot determine whether postmaster is running or not",
21682167
pid_file);
21692168
success = false;
@@ -2204,7 +2203,7 @@ check_incremental_compatibility(const char *pgdata, uint64 system_identifier,
22042203
*/
22052204
if (incremental_mode == INCR_LSN)
22062205
{
2207-
snprintf(backup_label, MAXPGPATH, "%s/backup_label", pgdata);
2206+
join_path_components(backup_label, pgdata, "backup_label");
22082207
if (fio_access(backup_label, F_OK, FIO_DB_HOST) == 0)
22092208
{
22102209
elog(WARNING, "Destination directory contains \"backup_control\" file. "

src/util.c

+1-49
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ set_min_recovery_point(pgFile *file, const char *backup_path,
418418
FIN_CRC32C(ControlFile.crc);
419419

420420
/* overwrite pg_control */
421-
snprintf(fullpath, sizeof(fullpath), "%s/%s", backup_path, XLOG_CONTROL_FILE);
421+
join_path_components(fullpath, backup_path, XLOG_CONTROL_FILE);
422422
writeControlFile(&ControlFile, fullpath, FIO_LOCAL_HOST);
423423

424424
/* Update pg_control checksum in backup_list */
@@ -579,51 +579,3 @@ datapagemap_print_debug(datapagemap_t *map)
579579

580580
pg_free(iter);
581581
}
582-
583-
/*
584-
* Return pid of postmaster process running in given pgdata.
585-
* Return 0 if there is none.
586-
* Return 1 if postmaster.pid is mangled.
587-
*/
588-
pid_t
589-
check_postmaster(const char *pgdata)
590-
{
591-
FILE *fp;
592-
pid_t pid;
593-
char pid_file[MAXPGPATH];
594-
595-
snprintf(pid_file, MAXPGPATH, "%s/postmaster.pid", pgdata);
596-
597-
fp = fopen(pid_file, "r");
598-
if (fp == NULL)
599-
{
600-
/* No pid file, acceptable*/
601-
if (errno == ENOENT)
602-
return 0;
603-
else
604-
elog(ERROR, "Cannot open file \"%s\": %s",
605-
pid_file, strerror(errno));
606-
}
607-
608-
if (fscanf(fp, "%i", &pid) != 1)
609-
{
610-
/* something is wrong with the file content */
611-
pid = 1;
612-
}
613-
614-
if (pid > 1)
615-
{
616-
if (kill(pid, 0) != 0)
617-
{
618-
/* process no longer exists */
619-
if (errno == ESRCH)
620-
pid = 0;
621-
else
622-
elog(ERROR, "Failed to send signal 0 to a process %d: %s",
623-
pid, strerror(errno));
624-
}
625-
}
626-
627-
fclose(fp);
628-
return pid;
629-
}

0 commit comments

Comments
 (0)