Skip to content

Commit 2df3953

Browse files
committed
Refactoring of includes and unused code
1 parent 0818889 commit 2df3953

27 files changed

+147
-470
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PROGRAM = pg_probackup
22
OBJS = src/backup.o src/catalog.o src/configure.o src/data.o \
33
src/delete.o src/dir.o src/fetch.o src/help.o src/init.o \
4-
src/pg_probackup.o src/restore.o src/show.o src/status.o \
4+
src/pg_probackup.o src/restore.o src/show.o \
55
src/util.o src/validate.o src/datapagemap.o src/parsexlog.o \
66
src/xlogreader.o src/streamutil.o src/receivelog.o \
77
src/archive.o src/utils/parray.o src/utils/pgut.o src/utils/logger.o \

gen_probackup_project.pl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ sub build_pgprobackup
145145
'pg_probackup.c',
146146
'restore.c',
147147
'show.c',
148-
'status.c',
149148
'util.c',
150149
'validate.c'
151150
);

src/archive.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
*
88
*-------------------------------------------------------------------------
99
*/
10-
#include "pg_probackup.h"
1110

1211
#include <unistd.h>
13-
#include <sys/stat.h>
12+
13+
#include "pg_probackup.h"
1414

1515
/*
1616
* pg_probackup specific archive command for archive backups

src/backup.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,29 @@
88
*-------------------------------------------------------------------------
99
*/
1010

11-
#include "pg_probackup.h"
12-
13-
#include <stdio.h>
14-
#include <stdlib.h>
15-
#include <string.h>
16-
#include <sys/stat.h>
17-
#include <sys/time.h>
18-
#include <unistd.h>
19-
#include <dirent.h>
20-
#include <time.h>
11+
#include "postgres_fe.h"
2112

22-
#include "catalog/catalog.h"
2313
#include "catalog/pg_tablespace.h"
24-
#include "datapagemap.h"
25-
#include "libpq/pqsignal.h"
2614
#include "pgtar.h"
2715
#include "receivelog.h"
28-
#include "storage/bufpage.h"
2916
#include "streamutil.h"
17+
18+
#include <sys/stat.h>
19+
#include <unistd.h>
20+
21+
#include "pg_probackup.h"
22+
3023
#include "utils/thread.h"
3124

25+
#define PG_STOP_BACKUP_TIMEOUT 300
26+
27+
/*
28+
* Macro needed to parse ptrack.
29+
* NOTE Keep those values syncronised with definitions in ptrack.h
30+
*/
31+
#define PTRACK_BITS_PER_HEAPBLOCK 1
32+
#define HEAPBLOCKS_PER_BYTE (BITS_PER_BYTE / PTRACK_BITS_PER_HEAPBLOCK)
33+
3234
static int standby_message_timeout = 10 * 1000; /* 10 sec = default */
3335
static XLogRecPtr stop_backup_lsn = InvalidXLogRecPtr;
3436
static XLogRecPtr stop_stream_lsn = InvalidXLogRecPtr;

src/catalog.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,13 @@
88
*-------------------------------------------------------------------------
99
*/
1010

11-
#include "pg_probackup.h"
12-
1311
#include <dirent.h>
14-
#include <fcntl.h>
1512
#include <signal.h>
16-
#include <sys/file.h>
1713
#include <sys/stat.h>
18-
#include <sys/types.h>
19-
#include <stdlib.h>
20-
#include <time.h>
2114
#include <unistd.h>
2215

16+
#include "pg_probackup.h"
17+
2318
static const char *backupModes[] = {"", "PAGE", "PTRACK", "DELTA", "FULL"};
2419
static pgBackup *readBackupControlFile(const char *path);
2520

src/configure.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
*/
99

1010
#include "pg_probackup.h"
11-
#include "utils/logger.h"
12-
13-
#include "pqexpbuffer.h"
1411

1512
#include "utils/json.h"
1613

src/data.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,27 @@
88
*-------------------------------------------------------------------------
99
*/
1010

11-
#include "pg_probackup.h"
12-
13-
#include <unistd.h>
14-
#include <time.h>
15-
#include <sys/types.h>
16-
#include <sys/stat.h>
11+
#include "postgres_fe.h"
1712

18-
#include "libpq/pqsignal.h"
19-
#include "storage/block.h"
20-
#include "storage/bufpage.h"
13+
#include "storage/checksum.h"
2114
#include "storage/checksum_impl.h"
2215
#include <common/pg_lzcompress.h>
2316

17+
#include <sys/stat.h>
18+
19+
#include "pg_probackup.h"
20+
2421
#ifdef HAVE_LIBZ
2522
#include <zlib.h>
2623
#endif
2724

25+
/* Union to ease operations on relation pages */
26+
typedef union DataPage
27+
{
28+
PageHeaderData page_data;
29+
char data[BLCKSZ];
30+
} DataPage;
31+
2832
#ifdef HAVE_LIBZ
2933
/* Implementation of zlib compression method */
3034
static int32

src/delete.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@
88
*-------------------------------------------------------------------------
99
*/
1010

11-
#include "pg_probackup.h"
12-
1311
#include <dirent.h>
1412
#include <time.h>
1513
#include <unistd.h>
1614

17-
static int pgBackupDeleteFiles(pgBackup *backup);
15+
#include "pg_probackup.h"
16+
17+
static int delete_backup_files(pgBackup *backup);
1818
static void delete_walfiles(XLogRecPtr oldest_lsn, TimeLineID oldest_tli,
1919
uint32 xlog_seg_size);
2020

21-
int
21+
void
2222
do_delete(time_t backup_id)
2323
{
2424
int i;
@@ -85,7 +85,7 @@ do_delete(time_t backup_id)
8585
if (interrupted)
8686
elog(ERROR, "interrupted during delete backup");
8787

88-
pgBackupDeleteFiles(backup);
88+
delete_backup_files(backup);
8989
}
9090

9191
parray_free(delete_list);
@@ -115,8 +115,6 @@ do_delete(time_t backup_id)
115115
/* cleanup */
116116
parray_walk(backup_list, pgBackupFree);
117117
parray_free(backup_list);
118-
119-
return 0;
120118
}
121119

122120
/*
@@ -205,7 +203,7 @@ do_retention_purge(void)
205203
}
206204

207205
/* Delete backup and update status to DELETED */
208-
pgBackupDeleteFiles(backup);
206+
delete_backup_files(backup);
209207
backup_deleted = true;
210208
}
211209
}
@@ -248,7 +246,7 @@ do_retention_purge(void)
248246
* BACKUP_STATUS_DELETED.
249247
*/
250248
static int
251-
pgBackupDeleteFiles(pgBackup *backup)
249+
delete_backup_files(pgBackup *backup)
252250
{
253251
size_t i;
254252
char path[MAXPGPATH];
@@ -433,7 +431,7 @@ do_delete_instance(void)
433431
for (i = 0; i < parray_num(backup_list); i++)
434432
{
435433
pgBackup *backup = (pgBackup *) parray_get(backup_list, i);
436-
pgBackupDeleteFiles(backup);
434+
delete_backup_files(backup);
437435
}
438436

439437
/* Cleanup */

src/dir.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,15 @@
88
*-------------------------------------------------------------------------
99
*/
1010

11-
#include "pg_probackup.h"
11+
#include "postgres_fe.h"
12+
13+
#include "catalog/pg_tablespace.h"
1214

1315
#include <unistd.h>
1416
#include <sys/stat.h>
15-
#include <sys/types.h>
1617
#include <dirent.h>
17-
#include <time.h>
1818

19-
#include "catalog/catalog.h"
20-
#include "catalog/pg_tablespace.h"
21-
#include "datapagemap.h"
19+
#include "pg_probackup.h"
2220

2321
/*
2422
* The contents of these directories are removed or recreated during server
@@ -1364,8 +1362,7 @@ dir_read_file_list(const char *root, const char *file_txt)
13641362

13651363
fp = fopen(file_txt, "rt");
13661364
if (fp == NULL)
1367-
elog(errno == ENOENT ? ERROR : ERROR,
1368-
"cannot open \"%s\": %s", file_txt, strerror(errno));
1365+
elog(ERROR, "cannot open \"%s\": %s", file_txt, strerror(errno));
13691366

13701367
files = parray_new();
13711368

src/fetch.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,8 @@
88
*-------------------------------------------------------------------------
99
*/
1010

11-
#include "postgres_fe.h"
12-
13-
#include "catalog/catalog.h"
14-
15-
#include <sys/types.h>
1611
#include <sys/stat.h>
17-
#include <dirent.h>
18-
#include <fcntl.h>
1912
#include <unistd.h>
20-
#include <string.h>
2113

2214
#include "pg_probackup.h"
2315

0 commit comments

Comments
 (0)