aboutsummaryrefslogtreecommitdiff
path: root/libjava/java
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2003-07-26 00:40:50 +0000
committerTom Tromey <tromey@gcc.gnu.org>2003-07-26 00:40:50 +0000
commit49f60a1a01b7526ca317f18dd0ed87f9ff781f3b (patch)
tree9875d1b9bc47a19b0c0f76f44a3bbecae0da6046 /libjava/java
parent037af9d77b4df0c1330e7fd641d6c97d9dbf2f9b (diff)
downloadgcc-49f60a1a01b7526ca317f18dd0ed87f9ff781f3b.zip
gcc-49f60a1a01b7526ca317f18dd0ed87f9ff781f3b.tar.gz
gcc-49f60a1a01b7526ca317f18dd0ed87f9ff781f3b.tar.bz2
natFileDescriptorPosix.cc (write): Try again on EINTR.
* java/io/natFileDescriptorPosix.cc (write): Try again on EINTR. (write): Likewise. (read): Likewise. (read): Likewise. From-SVN: r69807
Diffstat (limited to 'libjava/java')
-rw-r--r--libjava/java/io/natFileDescriptorPosix.cc60
1 files changed, 37 insertions, 23 deletions
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;
}