Skip to content

Commit 29adb5b

Browse files
committed
[Issue #228] fix remote mode
1 parent f9d3099 commit 29adb5b

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

src/data.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ backup_data_file(ConnectionArgs* conn_arg, pgFile *file,
829829

830830
/* handle hdr */
831831
/* TODO: move in separate function */
832-
if (headers)
832+
if (headers && file->n_headers > 0)
833833
{
834834
size_t hdr_size;
835835
char to_fullpath_hdr[MAXPGPATH];
@@ -862,10 +862,12 @@ backup_data_file(ConnectionArgs* conn_arg, pgFile *file,
862862
if (fclose(out))
863863
elog(ERROR, "Cannot close file \"%s\": %s", to_fullpath_hdr, strerror(errno));
864864

865-
// elog(INFO, "n_headers: %u", file->n_headers);
865+
/* TODO: fsync */
866866

867-
pg_free(headers);
867+
// elog(INFO, "n_headers: %u", file->n_headers);
868868
}
869+
870+
pg_free(headers);
869871
}
870872

871873
/*
@@ -1177,6 +1179,8 @@ restore_data_file_internal(FILE *in, FILE *out, pgFile *file, uint32 backup_vers
11771179
cur_pos_in = headers[n_hdr].pos;
11781180
}
11791181

1182+
// elog(INFO, "BKLKUM: %u", blknum);
1183+
11801184
// elog(INFO, "Cur_pos: %u", ftell(in));
11811185

11821186
/* read a page from file */

src/utils/file.c

+7-4
Original file line numberDiff line numberDiff line change
@@ -1519,8 +1519,6 @@ int fio_send_pages(FILE* out, const char *from_fullpath, pgFile *file, XLogRecPt
15191519
*headers = pgut_malloc(hdr.size);
15201520
IO_CHECK(fio_read_all(fio_stdin, *headers, hdr.size), hdr.size);
15211521
file->n_headers = hdr.size / sizeof(BackupPageHeader2);
1522-
1523-
// elog(INFO, "Size: %u", hdr.size);
15241522
}
15251523

15261524
break;
@@ -1795,9 +1793,14 @@ static void fio_send_pages_impl(int out, char* buf)
17951793
/* We are done, send eof */
17961794
hdr.cop = FIO_SEND_FILE_EOF;
17971795
hdr.arg = n_blocks_read;
1798-
hdr.size = (hdr_num+1) * sizeof(BackupPageHeader2);
1796+
hdr.size = 0;
1797+
1798+
if (headers)
1799+
hdr.size = (hdr_num+1) * sizeof(BackupPageHeader2);
17991800
IO_CHECK(fio_write_all(out, &hdr, sizeof(hdr)), sizeof(hdr));
1800-
IO_CHECK(fio_write_all(out, headers, hdr.size), hdr.size);
1801+
1802+
if (headers)
1803+
IO_CHECK(fio_write_all(out, headers, hdr.size), hdr.size);
18011804

18021805
/* send headers */
18031806
// hdr.cop = FIO_SEND_FILE_HEADERS;

src/utils/file.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ typedef enum
7171
typedef struct
7272
{
7373
// fio_operations cop;
74-
unsigned cop : 6;
75-
unsigned handle : 6;
76-
unsigned size : 20;
74+
// 16
75+
unsigned cop : 32;
76+
unsigned handle : 32;
77+
unsigned size : 32;
7778
unsigned arg;
7879
} fio_header;
7980

0 commit comments

Comments
 (0)