diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2018-11-07 08:08:45 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2018-11-07 08:08:45 +0200 |
commit | 59c82dde09984d10f16417c9c82cd759f81d770c (patch) | |
tree | e2cb02d72256cdf475ce7450a1d17675a392e6bc /mysys/my_pread.c | |
parent | ef40018535b71f0a4387fa6c1cc22e9991dfc0db (diff) | |
parent | 5f29fdecc0e22048e860ac256cc071ce206d453e (diff) | |
download | mariadb-git-59c82dde09984d10f16417c9c82cd759f81d770c.tar.gz |
Merge 10.0 into 10.1
Diffstat (limited to 'mysys/my_pread.c')
-rw-r--r-- | mysys/my_pread.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/mysys/my_pread.c b/mysys/my_pread.c index d3524279ea9..2b3bfdc9e3d 100644 --- a/mysys/my_pread.c +++ b/mysys/my_pread.c @@ -47,8 +47,7 @@ size_t my_pread(File Filedes, uchar *Buffer, size_t Count, my_off_t offset, myf MyFlags) { - size_t readbytes; - int error= 0; + size_t readbytes, save_count= 0; DBUG_ENTER("my_pread"); @@ -66,11 +65,10 @@ size_t my_pread(File Filedes, uchar *Buffer, size_t Count, my_off_t offset, #else readbytes= pread(Filedes, Buffer, Count, offset); #endif - error = (readbytes != Count); - if (error) + if (readbytes != Count) { - my_errno= errno ? errno : -1; + my_errno= errno; if (errno == 0 || (readbytes != (size_t) -1 && (MyFlags & (MY_NABP | MY_FNABP)))) my_errno= HA_ERR_FILE_TOO_SHORT; @@ -82,6 +80,18 @@ size_t my_pread(File Filedes, uchar *Buffer, size_t Count, my_off_t offset, (int) readbytes)); continue; /* Interrupted */ } + + /* Do a read retry if we didn't get enough data on first read */ + if (readbytes != (size_t) -1 && readbytes != 0 && + (MyFlags & MY_FULL_IO)) + { + Buffer+= readbytes; + Count-= readbytes; + save_count+= readbytes; + offset+= readbytes; + continue; + } + if (MyFlags & (MY_WME | MY_FAE | MY_FNABP)) { if (readbytes == (size_t) -1) @@ -97,8 +107,10 @@ size_t my_pread(File Filedes, uchar *Buffer, size_t Count, my_off_t offset, DBUG_RETURN(MY_FILE_ERROR); /* Return with error */ } if (MyFlags & (MY_NABP | MY_FNABP)) - DBUG_RETURN(0); /* Read went ok; Return 0 */ - DBUG_RETURN(readbytes); /* purecov: inspected */ + readbytes= 0; /* Read went ok; Return 0 */ + else + readbytes+= save_count; + DBUG_RETURN(readbytes); } } /* my_pread */ |