diff --git a/src/data.c b/src/data.c index f9c83e5d..2e1d034a 100644 --- a/src/data.c +++ b/src/data.c @@ -623,7 +623,7 @@ backup_data_file(ConnectionArgs* conn_arg, pgFile *file, } if (!fio_is_remote_file(in)) - setbuffer(in, in_buffer, STDIO_BUFSIZE); + setvbuf(in, in_buffer, _IOFBF, STDIO_BUFSIZE); /* open backup file for write */ out = fopen(to_fullpath, PG_BINARY_W); @@ -631,7 +631,7 @@ backup_data_file(ConnectionArgs* conn_arg, pgFile *file, elog(ERROR, "Cannot open backup file \"%s\": %s", to_fullpath, strerror(errno)); - setbuffer(out, out_buffer, STDIO_BUFSIZE); + setvbuf(out, out_buffer, _IOFBF, STDIO_BUFSIZE); /* update file permission */ if (chmod(to_fullpath, FILE_PERMISSION) == -1) @@ -874,7 +874,7 @@ restore_data_file(parray *parent_chain, pgFile *dest_file, FILE *out, const char elog(ERROR, "Cannot open backup file \"%s\": %s", from_fullpath, strerror(errno)); - setbuffer(in, buffer, STDIO_BUFSIZE); + setvbuf(in, buffer, _IOFBF, STDIO_BUFSIZE); /* * Restore the file. @@ -1164,7 +1164,7 @@ restore_non_data_file(parray *parent_chain, pgBackup *dest_backup, elog(ERROR, "Cannot open backup file \"%s\": %s", from_fullpath, strerror(errno)); - setbuffer(in, buffer, STDIO_BUFSIZE); + setvbuf(in, buffer, _IOFBF, STDIO_BUFSIZE); /* do actual work */ restore_non_data_file_internal(in, out, tmp_file, from_fullpath, to_fullpath); diff --git a/src/merge.c b/src/merge.c index 295d4230..06da8f4b 100644 --- a/src/merge.c +++ b/src/merge.c @@ -1132,7 +1132,7 @@ merge_data_file(parray *parent_chain, pgBackup *full_backup, if (out == NULL) elog(ERROR, "Cannot open merge target file \"%s\": %s", to_fullpath_tmp1, strerror(errno)); - setbuffer(out, buffer, STDIO_BUFSIZE); + setvbuf(out, buffer, _IOFBF, STDIO_BUFSIZE); /* restore file into temp file */ tmp_file->size = restore_data_file(parent_chain, dest_file, out, to_fullpath_tmp1); diff --git a/src/restore.c b/src/restore.c index 4bd62e09..177f9d5f 100644 --- a/src/restore.c +++ b/src/restore.c @@ -857,7 +857,7 @@ restore_files(void *arg) goto done; if (!fio_is_remote_file(out)) - setbuffer(out, buffer, STDIO_BUFSIZE); + setvbuf(out, buffer, _IOFBF, STDIO_BUFSIZE); /* Restore destination file */ if (dest_file->is_datafile && !dest_file->is_cfs)