aboutsummaryrefslogtreecommitdiff
path: root/libjava/java
diff options
context:
space:
mode:
authorBryce McKinlay <bryce@waitaki.otago.ac.nz>2001-09-21 04:23:31 +0000
committerBryce McKinlay <bryce@gcc.gnu.org>2001-09-21 05:23:31 +0100
commitf449e8853bf53ef866d346a99f707eb03488d434 (patch)
treec5d3ce7782681a64bb2752b4c6a1a0f42e3b24f5 /libjava/java
parent91d231cb917f53b4cd34dec24227863e95fceb6f (diff)
downloadgcc-f449e8853bf53ef866d346a99f707eb03488d434.zip
gcc-f449e8853bf53ef866d346a99f707eb03488d434.tar.gz
gcc-f449e8853bf53ef866d346a99f707eb03488d434.tar.bz2
posix-threads.cc (_Jv_ThreadInterrupt): Re-enable interrupt of blocking IO via pthread_kill().
* posix-threads.cc (_Jv_ThreadInterrupt): Re-enable interrupt of blocking IO via pthread_kill(). * java/io/natFileDescriptorPosix.cc (write (jint)): Check for thread interrupted status flag only if ::write returned an error. (write (jbyteArray, jint, jint): Likewise. (read (jint)): Likewise. (read (jbyteArray, jint, jint): Likewise. From-SVN: r45719
Diffstat (limited to 'libjava/java')
-rw-r--r--libjava/java/io/natFileDescriptorPosix.cc73
1 files changed, 40 insertions, 33 deletions
diff --git a/libjava/java/io/natFileDescriptorPosix.cc b/libjava/java/io/natFileDescriptorPosix.cc
index ad1c1cd..7c55f56 100644
--- a/libjava/java/io/natFileDescriptorPosix.cc
+++ b/libjava/java/io/natFileDescriptorPosix.cc
@@ -125,15 +125,17 @@ java::io::FileDescriptor::write (jint b)
while (r != 1)
{
r = ::write (fd, &d, 1);
- if (java::lang::Thread::interrupted())
- {
- InterruptedIOException *iioe
- = new InterruptedIOException (JvNewStringLatin1 ("write interrupted"));
- iioe->bytesTransferred = r == -1 ? 0 : r;
- throw iioe;
+ if (r == -1)
+ {
+ if (java::lang::Thread::interrupted())
+ {
+ InterruptedIOException *iioe
+ = new InterruptedIOException (JvNewStringLatin1 (strerror (errno)));
+ iioe->bytesTransferred = r == -1 ? 0 : r;
+ throw iioe;
+ }
+ throw new IOException (JvNewStringLatin1 (strerror (errno)));
}
- else if (r == -1)
- throw new IOException (JvNewStringLatin1 (strerror (errno)));
}
}
@@ -150,18 +152,19 @@ java::io::FileDescriptor::write (jbyteArray b, jint offset, jint len)
while (len > 0)
{
int r = ::write (fd, bytes, len);
- if (r != -1)
- written += r;
- if (java::lang::Thread::interrupted())
- {
- InterruptedIOException *iioe
- = new InterruptedIOException (JvNewStringLatin1 ("write interrupted"));
- iioe->bytesTransferred = written;
- throw iioe;
+ if (r == -1)
+ {
+ if (java::lang::Thread::interrupted())
+ {
+ InterruptedIOException *iioe
+ = new InterruptedIOException (JvNewStringLatin1 (strerror (errno)));
+ iioe->bytesTransferred = written;
+ throw iioe;
+ }
+ throw new IOException (JvNewStringLatin1 (strerror (errno)));
}
- else if (r == -1)
- throw new IOException (JvNewStringLatin1 (strerror (errno)));
+ written += r;
len -= r;
bytes += r;
}
@@ -222,15 +225,17 @@ java::io::FileDescriptor::read (void)
int r = ::read (fd, &b, 1);
if (r == 0)
return -1;
- if (java::lang::Thread::interrupted())
+ if (r == -1)
{
- InterruptedIOException *iioe
- = new InterruptedIOException (JvNewStringLatin1 ("read interrupted"));
- 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;
+ }
+ throw new IOException (JvNewStringLatin1 (strerror (errno)));
}
- else if (r == -1)
- throw new IOException (JvNewStringLatin1 (strerror (errno)));
return b & 0xFF;
}
@@ -246,15 +251,17 @@ java::io::FileDescriptor::read (jbyteArray buffer, jint offset, jint count)
int r = ::read (fd, bytes, count);
if (r == 0)
return -1;
- if (java::lang::Thread::interrupted())
- {
- InterruptedIOException *iioe
- = new InterruptedIOException (JvNewStringLatin1 ("read interrupted"));
- iioe->bytesTransferred = r == -1 ? 0 : r;
- throw iioe;
+ if (r == -1)
+ {
+ if (java::lang::Thread::interrupted())
+ {
+ InterruptedIOException *iioe
+ = new InterruptedIOException (JvNewStringLatin1 (strerror (errno)));
+ iioe->bytesTransferred = r == -1 ? 0 : r;
+ throw iioe;
+ }
+ throw new IOException (JvNewStringLatin1 (strerror (errno)));
}
- else if (r == -1)
- throw new IOException (JvNewStringLatin1 (strerror (errno)));
return r;
}