hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1361446 - in /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs: CHANGES.txt src/main/native/hdfs.c src/main/native/hdfs.h
Date Sat, 14 Jul 2012 00:03:59 GMT
Author: eli
Date: Sat Jul 14 00:03:58 2012
New Revision: 1361446

URL: http://svn.apache.org/viewvc?rev=1361446&view=rev
Log:
HDFS-470. libhdfs should handle 0-length reads from FSInputStream correctly. Contributed by
Colin Patrick McCabe

Modified:
    hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
    hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/native/hdfs.c
    hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/native/hdfs.h

Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1361446&r1=1361445&r2=1361446&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Sat Jul 14 00:03:58 2012
@@ -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)

Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/native/hdfs.c
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/native/hdfs.c?rev=1361446&r1=1361445&r2=1361446&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/native/hdfs.c (original)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/native/hdfs.c Sat Jul 14
00:03:58 2012
@@ -878,11 +878,15 @@ static int handleReadResult(int success,
     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;

Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/native/hdfs.h
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/native/hdfs.h?rev=1361446&r1=1361445&r2=1361446&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/native/hdfs.h (original)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/native/hdfs.h Sat Jul 14
00:03:58 2012
@@ -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);
 



Mime
View raw message