From ffde4de025b1ae9d4f7e8fd15fc3a06fe61da0b1 Mon Sep 17 00:00:00 2001 From: tromey Date: Sat, 26 Jul 2003 00:40:50 +0000 Subject: [PATCH] * java/io/natFileDescriptorPosix.cc (write): Try again on EINTR. (write): Likewise. (read): Likewise. (read): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@69807 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/ChangeLog | 7 ++++ libjava/java/io/natFileDescriptorPosix.cc | 60 +++++++++++++++++++------------ 2 files changed, 44 insertions(+), 23 deletions(-) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 5b447ee..05f433a 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,10 @@ +2003-07-25 Tom Tromey + + * java/io/natFileDescriptorPosix.cc (write): Try again on EINTR. + (write): Likewise. + (read): Likewise. + (read): Likewise. + 2003-07-25 Mark Wielaard * java/lang/natRuntime.cc (_load): Add library name to diff --git a/libjava/java/io/natFileDescriptorPosix.cc b/libjava/java/io/natFileDescriptorPosix.cc index 2ad2d9d..e43bb9d 100644 --- a/libjava/java/io/natFileDescriptorPosix.cc +++ b/libjava/java/io/natFileDescriptorPosix.cc @@ -150,7 +150,8 @@ java::io::FileDescriptor::write (jint b) iioe->bytesTransferred = r == -1 ? 0 : r; throw iioe; } - throw new IOException (JvNewStringLatin1 (strerror (errno))); + if (errno != EINTR) + throw new IOException (JvNewStringLatin1 (strerror (errno))); } } position++; @@ -178,7 +179,8 @@ java::io::FileDescriptor::write (jbyteArray b, jint offset, jint len) iioe->bytesTransferred = written; throw iioe; } - throw new IOException (JvNewStringLatin1 (strerror (errno))); + if (errno != EINTR) + throw new IOException (JvNewStringLatin1 (strerror (errno))); } written += r; @@ -282,20 +284,26 @@ jint java::io::FileDescriptor::read (void) { jbyte b; - int r = ::read (fd, &b, 1); - if (r == 0) - return -1; - if (r == -1) + int r; + do { - if (java::lang::Thread::interrupted()) + r = ::read (fd, &b, 1); + if (r == 0) + return -1; + if (r == -1) { - InterruptedIOException *iioe - = new InterruptedIOException (JvNewStringLatin1 (strerror (errno))); - iioe->bytesTransferred = r == -1 ? 0 : r; - throw iioe; + if (java::lang::Thread::interrupted()) + { + InterruptedIOException *iioe + = new InterruptedIOException (JvNewStringLatin1 (strerror (errno))); + iioe->bytesTransferred = r == -1 ? 0 : r; + throw iioe; + } + if (errno != EINTR) + throw new IOException (JvNewStringLatin1 (strerror (errno))); } - throw new IOException (JvNewStringLatin1 (strerror (errno))); } + while (r != 1); position++; return b & 0xFF; } @@ -314,20 +322,26 @@ java::io::FileDescriptor::read (jbyteArray buffer, jint offset, jint count) return 0; jbyte *bytes = elements (buffer) + offset; - int r = ::read (fd, bytes, count); - if (r == 0) - return -1; - if (r == -1) - { - if (java::lang::Thread::interrupted()) + int r; + do + { + r = ::read (fd, bytes, count); + if (r == 0) + return -1; + if (r == -1) { - InterruptedIOException *iioe - = new InterruptedIOException (JvNewStringLatin1 (strerror (errno))); - iioe->bytesTransferred = r == -1 ? 0 : r; - throw iioe; + if (java::lang::Thread::interrupted()) + { + InterruptedIOException *iioe + = new InterruptedIOException (JvNewStringLatin1 (strerror (errno))); + iioe->bytesTransferred = r == -1 ? 0 : r; + throw iioe; + } + if (errno != EINTR) + throw new IOException (JvNewStringLatin1 (strerror (errno))); } - throw new IOException (JvNewStringLatin1 (strerror (errno))); } + while (r <= 0); position += r; return r; } -- 2.7.4