Commit f449e885 by Bryce McKinlay Committed by Bryce McKinlay

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
parent 91d231cb
2001-09-20 Bryce McKinlay <bryce@waitaki.otago.ac.nz>
* 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.
2001-09-19 Anthony Green <green@redhat.com> 2001-09-19 Anthony Green <green@redhat.com>
* gnu/gcj/protocol/file/Handler.java: Avoid NullPointerException * gnu/gcj/protocol/file/Handler.java: Avoid NullPointerException
......
...@@ -125,16 +125,18 @@ java::io::FileDescriptor::write (jint b) ...@@ -125,16 +125,18 @@ java::io::FileDescriptor::write (jint b)
while (r != 1) while (r != 1)
{ {
r = ::write (fd, &d, 1); r = ::write (fd, &d, 1);
if (r == -1)
{
if (java::lang::Thread::interrupted()) if (java::lang::Thread::interrupted())
{ {
InterruptedIOException *iioe InterruptedIOException *iioe
= new InterruptedIOException (JvNewStringLatin1 ("write interrupted")); = new InterruptedIOException (JvNewStringLatin1 (strerror (errno)));
iioe->bytesTransferred = r == -1 ? 0 : r; iioe->bytesTransferred = r == -1 ? 0 : r;
throw iioe; throw iioe;
} }
else if (r == -1)
throw new IOException (JvNewStringLatin1 (strerror (errno))); throw new IOException (JvNewStringLatin1 (strerror (errno)));
} }
}
} }
void void
...@@ -150,18 +152,19 @@ java::io::FileDescriptor::write (jbyteArray b, jint offset, jint len) ...@@ -150,18 +152,19 @@ java::io::FileDescriptor::write (jbyteArray b, jint offset, jint len)
while (len > 0) while (len > 0)
{ {
int r = ::write (fd, bytes, len); int r = ::write (fd, bytes, len);
if (r != -1) if (r == -1)
written += r; {
if (java::lang::Thread::interrupted()) if (java::lang::Thread::interrupted())
{ {
InterruptedIOException *iioe InterruptedIOException *iioe
= new InterruptedIOException (JvNewStringLatin1 ("write interrupted")); = new InterruptedIOException (JvNewStringLatin1 (strerror (errno)));
iioe->bytesTransferred = written; iioe->bytesTransferred = written;
throw iioe; throw iioe;
} }
else if (r == -1)
throw new IOException (JvNewStringLatin1 (strerror (errno))); throw new IOException (JvNewStringLatin1 (strerror (errno)));
}
written += r;
len -= r; len -= r;
bytes += r; bytes += r;
} }
...@@ -222,15 +225,17 @@ java::io::FileDescriptor::read (void) ...@@ -222,15 +225,17 @@ java::io::FileDescriptor::read (void)
int r = ::read (fd, &b, 1); int r = ::read (fd, &b, 1);
if (r == 0) if (r == 0)
return -1; return -1;
if (r == -1)
{
if (java::lang::Thread::interrupted()) if (java::lang::Thread::interrupted())
{ {
InterruptedIOException *iioe InterruptedIOException *iioe
= new InterruptedIOException (JvNewStringLatin1 ("read interrupted")); = new InterruptedIOException (JvNewStringLatin1 (strerror (errno)));
iioe->bytesTransferred = r == -1 ? 0 : r; iioe->bytesTransferred = r == -1 ? 0 : r;
throw iioe; throw iioe;
} }
else if (r == -1)
throw new IOException (JvNewStringLatin1 (strerror (errno))); throw new IOException (JvNewStringLatin1 (strerror (errno)));
}
return b & 0xFF; return b & 0xFF;
} }
...@@ -246,15 +251,17 @@ java::io::FileDescriptor::read (jbyteArray buffer, jint offset, jint count) ...@@ -246,15 +251,17 @@ java::io::FileDescriptor::read (jbyteArray buffer, jint offset, jint count)
int r = ::read (fd, bytes, count); int r = ::read (fd, bytes, count);
if (r == 0) if (r == 0)
return -1; return -1;
if (r == -1)
{
if (java::lang::Thread::interrupted()) if (java::lang::Thread::interrupted())
{ {
InterruptedIOException *iioe InterruptedIOException *iioe
= new InterruptedIOException (JvNewStringLatin1 ("read interrupted")); = new InterruptedIOException (JvNewStringLatin1 (strerror (errno)));
iioe->bytesTransferred = r == -1 ? 0 : r; iioe->bytesTransferred = r == -1 ? 0 : r;
throw iioe; throw iioe;
} }
else if (r == -1)
throw new IOException (JvNewStringLatin1 (strerror (errno))); throw new IOException (JvNewStringLatin1 (strerror (errno)));
}
return r; return r;
} }
......
...@@ -263,7 +263,7 @@ _Jv_ThreadInterrupt (_Jv_Thread_t *data) ...@@ -263,7 +263,7 @@ _Jv_ThreadInterrupt (_Jv_Thread_t *data)
data->thread_obj->interrupt_flag = true; data->thread_obj->interrupt_flag = true;
// Interrupt blocking system calls using a signal. // Interrupt blocking system calls using a signal.
// pthread_kill (data->thread, INTR); pthread_kill (data->thread, INTR);
pthread_cond_signal (&data->wait_cond); pthread_cond_signal (&data->wait_cond);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment