summaryrefslogtreecommitdiffstats
path: root/src/H5FDlog.c
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2019-12-09 05:52:29 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2019-12-09 05:52:29 (GMT)
commit99f85cbf15a637768c8df977ddc5eebe7683a60d (patch)
tree5cbb9ed463a10e112e28bb588160ee6242cac790 /src/H5FDlog.c
parentc7b3d6d6a5c1d376812e17c0ddb26f55334a2c59 (diff)
downloadhdf5-99f85cbf15a637768c8df977ddc5eebe7683a60d.zip
hdf5-99f85cbf15a637768c8df977ddc5eebe7683a60d.tar.gz
hdf5-99f85cbf15a637768c8df977ddc5eebe7683a60d.tar.bz2
Fixed bugs in pread/pwrite I/O in VFDs.
Fixes HDFFV-10945.
Diffstat (limited to 'src/H5FDlog.c')
-rw-r--r--src/H5FDlog.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/H5FDlog.c b/src/H5FDlog.c
index ac5667f..60255e5 100644
--- a/src/H5FDlog.c
+++ b/src/H5FDlog.c
@@ -1171,6 +1171,7 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hadd
#ifdef H5_HAVE_GETTIMEOFDAY
struct timeval timeval_start, timeval_stop;
#endif /* H5_HAVE_GETTIMEOFDAY */
+ HDoff_t offset = (HDoff_t)addr;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -1255,7 +1256,6 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hadd
h5_posix_io_t bytes_in = 0; /* # of bytes to read */
h5_posix_io_ret_t bytes_read = -1; /* # of bytes actually read */
- HDoff_t offset = (HDoff_t)addr;
/* Trying to read more bytes than the return type can handle is
* undefined behavior in POSIX.
@@ -1268,7 +1268,8 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hadd
do {
#ifdef H5_HAVE_PREADWRITE
bytes_read = HDpread(file->fd, buf, bytes_in, offset);
- offset += bytes_read;
+ if(bytes_read > 0)
+ offset += bytes_read;
#else
bytes_read = HDread(file->fd, buf, bytes_in);
#endif /* H5_HAVE_PREADWRITE */
@@ -1382,6 +1383,7 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had
#ifdef H5_HAVE_GETTIMEOFDAY
struct timeval timeval_start, timeval_stop;
#endif /* H5_HAVE_GETTIMEOFDAY */
+ HDoff_t offset = (HDoff_t)addr;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -1471,7 +1473,6 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had
h5_posix_io_t bytes_in = 0; /* # of bytes to write */
h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes written */
- HDoff_t offset = (HDoff_t)addr;
/* Trying to write more bytes than the return type can handle is
* undefined behavior in POSIX.
@@ -1484,7 +1485,8 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had
do {
#ifdef H5_HAVE_PREADWRITE
bytes_wrote = HDpwrite(file->fd, buf, bytes_in, offset);
- offset += bytes_wrote;
+ if(bytes_wrote > 0)
+ offset += bytes_wrote;
#else
bytes_wrote = HDwrite(file->fd, buf, bytes_in);
#endif /* H5_HAVE_PREADWRITE */