HDFS-470. libhdfs should handle 0-length reads from FSInputStream correctly. Contributed by Colin Patrick McCabe
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1361446 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
dcf0ac7a8a
commit
8c2a2f909c
@ -477,6 +477,9 @@ Branch-2 ( Unreleased changes )
|
||||
HDFS-3639. JspHelper#getUGI should always verify the token if
|
||||
security is enabled. (eli)
|
||||
|
||||
HDFS-470. libhdfs should handle 0-length reads from FSInputStream
|
||||
correctly. (Colin Patrick McCabe via eli)
|
||||
|
||||
BREAKDOWN OF HDFS-3042 SUBTASKS
|
||||
|
||||
HDFS-2185. HDFS portion of ZK-based FailoverController (todd)
|
||||
|
@ -878,11 +878,15 @@ static int handleReadResult(int success, jvalue jVal, jthrowable jExc,
|
||||
noReadBytes = -1;
|
||||
} else {
|
||||
noReadBytes = jVal.i;
|
||||
if (noReadBytes < 0) {
|
||||
if (noReadBytes == 0) {
|
||||
// 0 from Java means try again, which is EINTR here
|
||||
errno = EINTR;
|
||||
noReadBytes = -1;
|
||||
} else if (noReadBytes < 0) {
|
||||
// -1 from Java is EOF, which is 0 here
|
||||
errno = 0;
|
||||
noReadBytes = 0;
|
||||
}
|
||||
errno = 0;
|
||||
}
|
||||
|
||||
return noReadBytes;
|
||||
|
@ -311,8 +311,13 @@ extern "C" {
|
||||
* @param file The file handle.
|
||||
* @param buffer The buffer to copy read bytes into.
|
||||
* @param length The length of the buffer.
|
||||
* @return Returns the number of bytes actually read, possibly less
|
||||
* than than length;-1 on error.
|
||||
* @return On success, a positive number indicating how many bytes
|
||||
* were read.
|
||||
* On end-of-file, 0.
|
||||
* On error, -1. Errno will be set to the error code.
|
||||
* Just like the POSIX read function, hdfsRead will return -1
|
||||
* and set errno to EINTR if data is temporarily unavailable,
|
||||
* but we are not yet at the end of the file.
|
||||
*/
|
||||
tSize hdfsRead(hdfsFS fs, hdfsFile file, void* buffer, tSize length);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user