1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2025-02-17 15:24:28 +02:00

[refer #PGPRO-1745] Fix PREAD agent command

This commit is contained in:
Konstantin Knizhnik 2019-02-01 16:17:12 +03:00
parent df4ede9812
commit f5a7ba34d2

View File

@ -177,7 +177,7 @@ struct dirent* fio_readdir(DIR *dir)
if (fio_is_remote_file((FILE*)dir))
{
fio_header hdr;
static struct dirent entry;
static __thread struct dirent entry;
hdr.cop = FIO_READDIR;
hdr.handle = (size_t)dir - 1;
@ -838,6 +838,7 @@ void fio_communicate(int in, int out)
break;
case FIO_OPEN:
SYS_CHECK(fd[hdr.handle] = open(buf, hdr.arg, FILE_PERMISSIONS));
fprintf(stderr, "Open file %s -> %d\n", buf, hdr.handle);
break;
case FIO_CLOSE:
SYS_CHECK(close(fd[hdr.handle]));
@ -857,12 +858,9 @@ void fio_communicate(int in, int out)
IO_CHECK(fio_write_all(out, buf, hdr.size), hdr.size);
break;
case FIO_PREAD:
if ((size_t)hdr.arg > buf_size) {
buf_size = hdr.arg;
buf = (char*)realloc(buf, buf_size);
}
horizon_lsn = *(XLogRecPtr*)buf;
rc = pread(fd[hdr.handle], buf, hdr.arg, BLCKSZ);
rc = pread(fd[hdr.handle], buf, BLCKSZ, hdr.arg);
fprintf(stderr, "Read %d bytes from file %d offset %d\n", rc, hdr.handle, hdr.arg);
hdr.cop = FIO_SEND;
hdr.arg = rc;
hdr.size = (rc == BLCKSZ)