Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit13a1821

Browse files
committed
Merge branch 'master' into release_2_5
2 parents02ca67d +8ae217b commit13a1821

File tree

2 files changed

+33
-10
lines changed

2 files changed

+33
-10
lines changed

‎src/archive.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,7 @@ push_file_internal_uncompressed(const char *wal_file_name, const char *pg_xlog_d
568568
}
569569

570570
/* copy content */
571+
errno=0;
571572
for (;;)
572573
{
573574
size_tread_len=0;

‎src/utils/file.c

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,34 @@ fio_fwrite_async(FILE* f, void const* buf, size_t size)
814814
:fwrite(buf,1,size,f);
815815
}
816816

817+
/*
818+
* Write buffer to descriptor by calling write(),
819+
* If size of written data is less than buffer size,
820+
* then try to write what is left.
821+
* We do this to get honest errno if there are some problems
822+
* with filesystem, since writing less than buffer size
823+
* is not considered an error.
824+
*/
825+
staticssize_t
826+
durable_write(intfd,constchar*buf,size_tsize)
827+
{
828+
off_tcurrent_pos=0;
829+
size_tbytes_left=size;
830+
831+
while (bytes_left>0)
832+
{
833+
intrc=write(fd,buf+current_pos,bytes_left);
834+
835+
if (rc <=0)
836+
returnrc;
837+
838+
bytes_left-=rc;
839+
current_pos+=rc;
840+
}
841+
842+
returnsize;
843+
}
844+
817845
/* Write data to the file */
818846
/* TODO: support async report error */
819847
ssize_t
@@ -832,27 +860,21 @@ fio_write_async(int fd, void const* buf, size_t size)
832860

833861
IO_CHECK(fio_write_all(fio_stdout,&hdr,sizeof(hdr)),sizeof(hdr));
834862
IO_CHECK(fio_write_all(fio_stdout,buf,size),size);
835-
836-
returnsize;
837863
}
838864
else
839-
{
840-
returnwrite(fd,buf,size);
841-
}
865+
returndurable_write(fd,buf,size);
866+
867+
returnsize;
842868
}
843869

844870
staticvoid
845871
fio_write_async_impl(intfd,voidconst*buf,size_tsize,intout)
846872
{
847-
intrc;
848-
849873
/* Quick exit if agent is tainted */
850874
if (async_errormsg)
851875
return;
852876

853-
rc=write(fd,buf,size);
854-
855-
if (rc <=0)
877+
if (durable_write(fd,buf,size) <=0)
856878
{
857879
async_errormsg=pgut_malloc(ERRMSG_MAX_LEN);
858880
snprintf(async_errormsg,ERRMSG_MAX_LEN,"%s",strerror(errno));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp