1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2024-11-28 09:33:54 +02:00

[Issue #228] fix remote mode

This commit is contained in:
Grigory Smolkin 2020-06-16 01:51:39 +03:00
parent f9d3099598
commit 29adb5bfdf
3 changed files with 18 additions and 10 deletions

View File

@ -829,7 +829,7 @@ cleanup:
/* handle hdr */
/* TODO: move in separate function */
if (headers)
if (headers && file->n_headers > 0)
{
size_t hdr_size;
char to_fullpath_hdr[MAXPGPATH];
@ -862,10 +862,12 @@ cleanup:
if (fclose(out))
elog(ERROR, "Cannot close file \"%s\": %s", to_fullpath_hdr, strerror(errno));
// elog(INFO, "n_headers: %u", file->n_headers);
/* TODO: fsync */
pg_free(headers);
// elog(INFO, "n_headers: %u", file->n_headers);
}
pg_free(headers);
}
/*
@ -1177,6 +1179,8 @@ restore_data_file_internal(FILE *in, FILE *out, pgFile *file, uint32 backup_vers
cur_pos_in = headers[n_hdr].pos;
}
// elog(INFO, "BKLKUM: %u", blknum);
// elog(INFO, "Cur_pos: %u", ftell(in));
/* read a page from file */

View File

@ -1519,8 +1519,6 @@ int fio_send_pages(FILE* out, const char *from_fullpath, pgFile *file, XLogRecPt
*headers = pgut_malloc(hdr.size);
IO_CHECK(fio_read_all(fio_stdin, *headers, hdr.size), hdr.size);
file->n_headers = hdr.size / sizeof(BackupPageHeader2);
// elog(INFO, "Size: %u", hdr.size);
}
break;
@ -1795,9 +1793,14 @@ eof:
/* We are done, send eof */
hdr.cop = FIO_SEND_FILE_EOF;
hdr.arg = n_blocks_read;
hdr.size = (hdr_num+1) * sizeof(BackupPageHeader2);
hdr.size = 0;
if (headers)
hdr.size = (hdr_num+1) * sizeof(BackupPageHeader2);
IO_CHECK(fio_write_all(out, &hdr, sizeof(hdr)), sizeof(hdr));
IO_CHECK(fio_write_all(out, headers, hdr.size), hdr.size);
if (headers)
IO_CHECK(fio_write_all(out, headers, hdr.size), hdr.size);
/* send headers */
// hdr.cop = FIO_SEND_FILE_HEADERS;

View File

@ -71,9 +71,10 @@ typedef enum
typedef struct
{
// fio_operations cop;
unsigned cop : 6;
unsigned handle : 6;
unsigned size : 20;
// 16
unsigned cop : 32;
unsigned handle : 32;
unsigned size : 32;
unsigned arg;
} fio_header;