aboutsummaryrefslogtreecommitdiff
path: root/java/jdk16/files/patch-j2se::nio::ch::FileChannelImpl.c
blob: 8dea374d17f30169317e8007fc5064f328ecee64 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
$FreeBSD$

--- ../../j2se/src/solaris/native/sun/nio/ch/FileChannelImpl.c.orig	Fri Jul  7 10:47:18 2006
+++ ../../j2se/src/solaris/native/sun/nio/ch/FileChannelImpl.c	Fri Jul  7 14:48:06 2006
@@ -273,14 +273,28 @@
     free(buf);
 
     /*
-     * XXXBSD: there're potential problems with NBIO fd's.  Check it.
+     * Similar to solaris if we've transferred any data return
+     * the number of bytes and ignore any error
+    */
+    if (offset - (off_t)position > 0)
+	return (offset - (off_t)position);
+
+    /*
+     * Deal with NBIO EAGAIN & EINTR the same as solaris. 
      */
     if (r == -1 || w == -1) {
-	fprintf(stderr, "%d %d %d %d %d\n", srcFD, dstFD, r, w, errno);
-	JNU_ThrowIOExceptionWithLastError(env, "Transfer failed");
-	return IOS_THROWN;
+        switch (errno) {
+	    case EAGAIN:
+	        return IOS_UNAVAILABLE;
+	    case EINTR:
+	        return IOS_INTERRUPTED;
+	    default:
+		JNU_ThrowIOExceptionWithLastError(env, "Transfer failed");
+		return IOS_THROWN;
+        }
     }
-    return (offset - (off_t)position);
+
+    return (0);
 #endif
 }