Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a490120

Browse files
committed
Correctly set binary mode for SSH pipe
1 parent 16fff38 commit a490120

File tree

3 files changed

+9
-16
lines changed

3 files changed

+9
-16
lines changed

src/pg_probackup.h

-12
Original file line numberDiff line numberDiff line change
@@ -679,16 +679,4 @@ extern bool parse_page(Page page, XLogRecPtr *lsn);
679679
int32 do_compress(void* dst, size_t dst_size, void const* src, size_t src_size,
680680
CompressAlg alg, int level, const char **errormsg);
681681

682-
#ifdef WIN32
683-
#ifdef _DEBUG
684-
#define lseek _lseek
685-
#define open _open
686-
#define fstat _fstat
687-
#define read _read
688-
#define close _close
689-
#define write _write
690-
#define mkdir(dir,mode) _mkdir(dir)
691-
#endif
692-
#endif
693-
694682
#endif /* PG_PROBACKUP_H */

src/utils/file.c

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <sys/stat.h>
44

55
#ifdef WIN32
6-
#define __thread
6+
#define __thread __declspec(thread)
77
#else
88
#include <pthread.h>
99
#endif
@@ -1258,7 +1258,12 @@ void fio_communicate(int in, int out)
12581258
struct stat st;
12591259
int rc;
12601260

1261-
/* Main loop until command of processing master command */
1261+
#ifdef WIN32
1262+
SYS_CHECK(setmode(in, _O_BINARY));
1263+
SYS_CHECK(setmode(out, _O_BINARY));
1264+
#endif
1265+
1266+
/* Main loop until command of processing master command */
12621267
while ((rc = fio_read_all(in, &hdr, sizeof hdr)) == sizeof(hdr)) {
12631268
if (hdr.size != 0) {
12641269
if (hdr.size > buf_size) {

src/utils/remote.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ bool launch_agent(void)
148148
}
149149

150150
#ifdef WIN32
151-
SYS_CHECK(_pipe(infd, PIPE_SIZE, O_BINARY)) ;
152-
SYS_CHECK(_pipe(outfd, PIPE_SIZE, O_BINARY));
151+
SYS_CHECK(_pipe(infd, PIPE_SIZE, _O_BINARY)) ;
152+
SYS_CHECK(_pipe(outfd, PIPE_SIZE, _O_BINARY));
153153
ssh_argv[2] = psprintf("%d", outfd[0]);
154154
ssh_argv[3] = psprintf("%d", infd[1]);
155155
{

0 commit comments

Comments
 (0)