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

Commitce97a8d

Browse files
committed
move check_postmaster() into src/utils/file.c (from src/util.c), rename it to local_check_postmaster() and make it static/private to src/utils/file.c
1 parent27582c1 commitce97a8d

File tree

4 files changed

+50
-53
lines changed

4 files changed

+50
-53
lines changed

‎src/pg_probackup.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,8 +1071,6 @@ extern PageState *get_checksum_map(const char *fullpath, uint32 checksum_version
10711071
intn_blocks,XLogRecPtrdest_stop_lsn,BlockNumbersegmentno);
10721072
externdatapagemap_t*get_lsn_map(constchar*fullpath,uint32checksum_version,
10731073
intn_blocks,XLogRecPtrshift_lsn,BlockNumbersegmentno);
1074-
externpid_tcheck_postmaster(constchar*pgdata);
1075-
10761074
externboolvalidate_file_pages(pgFile*file,constchar*fullpath,XLogRecPtrstop_lsn,
10771075
uint32checksum_version,uint32backup_version,HeaderMap*hdr_map);
10781076

‎src/util.c‎

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -556,51 +556,3 @@ datapagemap_print_debug(datapagemap_t *map)
556556

557557
pg_free(iter);
558558
}
559-
560-
/*
561-
* Return pid of postmaster process running in given pgdata.
562-
* Return 0 if there is none.
563-
* Return 1 if postmaster.pid is mangled.
564-
*/
565-
pid_t
566-
check_postmaster(constchar*pgdata)
567-
{
568-
FILE*fp;
569-
pid_tpid;
570-
charpid_file[MAXPGPATH];
571-
572-
join_path_components(pid_file,pgdata,"postmaster.pid");
573-
574-
fp=fopen(pid_file,"r");
575-
if (fp==NULL)
576-
{
577-
/* No pid file, acceptable*/
578-
if (errno==ENOENT)
579-
return0;
580-
else
581-
elog(ERROR,"Cannot open file \"%s\": %s",
582-
pid_file,strerror(errno));
583-
}
584-
585-
if (fscanf(fp,"%i",&pid)!=1)
586-
{
587-
/* something is wrong with the file content */
588-
pid=1;
589-
}
590-
591-
if (pid>1)
592-
{
593-
if (kill(pid,0)!=0)
594-
{
595-
/* process no longer exists */
596-
if (errno==ESRCH)
597-
pid=0;
598-
else
599-
elog(ERROR,"Failed to send signal 0 to a process %d: %s",
600-
pid,strerror(errno));
601-
}
602-
}
603-
604-
fclose(fp);
605-
returnpid;
606-
}

‎src/utils/file.c‎

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2771,6 +2771,54 @@ fio_get_lsn_map_impl(int out, char *buf)
27712771
}
27722772
}
27732773

2774+
/*
2775+
* Return pid of postmaster process running in given pgdata on local machine.
2776+
* Return 0 if there is none.
2777+
* Return 1 if postmaster.pid is mangled.
2778+
*/
2779+
staticpid_t
2780+
local_check_postmaster(constchar*pgdata)
2781+
{
2782+
FILE*fp;
2783+
pid_tpid;
2784+
charpid_file[MAXPGPATH];
2785+
2786+
join_path_components(pid_file,pgdata,"postmaster.pid");
2787+
2788+
fp=fopen(pid_file,"r");
2789+
if (fp==NULL)
2790+
{
2791+
/* No pid file, acceptable*/
2792+
if (errno==ENOENT)
2793+
return0;
2794+
else
2795+
elog(ERROR,"Cannot open file \"%s\": %s",
2796+
pid_file,strerror(errno));
2797+
}
2798+
2799+
if (fscanf(fp,"%i",&pid)!=1)
2800+
{
2801+
/* something is wrong with the file content */
2802+
pid=1;
2803+
}
2804+
2805+
if (pid>1)
2806+
{
2807+
if (kill(pid,0)!=0)
2808+
{
2809+
/* process no longer exists */
2810+
if (errno==ESRCH)
2811+
pid=0;
2812+
else
2813+
elog(ERROR,"Failed to send signal 0 to a process %d: %s",
2814+
pid,strerror(errno));
2815+
}
2816+
}
2817+
2818+
fclose(fp);
2819+
returnpid;
2820+
}
2821+
27742822
/*
27752823
* Go to the remote host and get postmaster pid from file postmaster.pid
27762824
* and check that process is running, if process is running, return its pid number.
@@ -2793,7 +2841,7 @@ fio_check_postmaster(const char *pgdata, fio_location location)
27932841
returnhdr.arg;
27942842
}
27952843
else
2796-
returncheck_postmaster(pgdata);
2844+
returnlocal_check_postmaster(pgdata);
27972845
}
27982846

27992847
staticvoid
@@ -2803,7 +2851,7 @@ fio_check_postmaster_impl(int out, char *buf)
28032851
pid_tpostmaster_pid;
28042852
char*pgdata= (char*)buf;
28052853

2806-
postmaster_pid=check_postmaster(pgdata);
2854+
postmaster_pid=local_check_postmaster(pgdata);
28072855

28082856
/* send arrays of checksums to main process */
28092857
hdr.arg=postmaster_pid;

‎src/utils/file.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,3 @@ extern const char* fio_gzerror(gzFile file, int *errnum);
145145
#endif
146146

147147
#endif
148-

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp