mirror of
https://git.freebsd.org/ports.git
synced 2025-07-18 17:59:20 -04:00
. Properly deal with error cases in transferTo0().
Corrects non-blocking IO case. Submitted by: Kurt Miller <kurt@intricatesoftware.com> Sponsored by: The FreeBSD Foundation
This commit is contained in:
parent
7c58e0c63e
commit
c9d5a55e98
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=168175
2 changed files with 76 additions and 0 deletions
38
java/jdk15/files/patch-j2se::nio::ch::FileChannelImpl.c
Normal file
38
java/jdk15/files/patch-j2se::nio::ch::FileChannelImpl.c
Normal file
|
@ -0,0 +1,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
|
||||
}
|
||||
|
38
java/jdk16/files/patch-j2se::nio::ch::FileChannelImpl.c
Normal file
38
java/jdk16/files/patch-j2se::nio::ch::FileChannelImpl.c
Normal file
|
@ -0,0 +1,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
|
||||
}
|
||||
|
Loading…
Add table
Reference in a new issue