Skip to content

Commit

Permalink
configure.ac: add pwritev check
Browse files Browse the repository at this point in the history
Signed-off-by: Haomai Wang <[email protected]>
  • Loading branch information
yuyuyu101 committed Jan 30, 2016
1 parent aa7b505 commit b1e27a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,7 @@ AC_CHECK_HEADERS([sys/prctl.h])
AC_CHECK_FUNCS([prctl])
AC_CHECK_FUNCS([pipe2])
AC_CHECK_FUNCS([posix_fadvise])
AC_CHECK_FUNCS([pwritev], AC_DEFINE([HAVE_PWRITEV], [1], [we have pwritev]))

AC_MSG_CHECKING([for fdatasync])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Expand Down
12 changes: 11 additions & 1 deletion src/common/buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1954,8 +1954,18 @@ int buffer::list::write_file(const char *fn, int mode)

static int do_writev(int fd, struct iovec *vec, uint64_t offset, unsigned veclen, unsigned bytes)
{
ssize_t r = 0;
while (bytes > 0) {
ssize_t r = ::pwritev(fd, vec, veclen, offset);
#ifdef HAVE_PWRITEV
r = ::pwritev(fd, vec, veclen, offset);
#else
r = ::lseek64(fd, offset, SEEK_SET);
if (r != offset) {
r = -errno;
return r;
}
r = ::writev(fd, vec, veclen);
#endif
if (r < 0) {
if (errno == EINTR)
continue;
Expand Down

0 comments on commit b1e27a5

Please sign in to comment.