natPlainSocketImplPosix.cc (connect): Pass the FD as a ready-to-write argument to _Jv_Select.
* java/net/natPlainSocketImplPosix.cc (connect): Pass the FD as a ready-to-write argument to _Jv_Select. Reset the socket back to non-blocking state after connecting. (accept): Pass the FD as a ready-to-write argument to _Jv_Select. Throw SocketTimeoutException not InterruptedIOException. (read): Throw SocketTimeoutException not InterruptedIOException. Co-Authored-By: Bryce McKinlay <bryce@mckinlay.net.nz> From-SVN: r70217
This commit is contained in:
parent
6eac0ef54e
commit
7c6e92558c
2 changed files with 26 additions and 15 deletions
|
@ -1,3 +1,13 @@
|
||||||
|
2003-08-07 Jacob Gladish <gladish@spinnakernet.com>
|
||||||
|
Bryce McKinlay <bryce@mckinlay.net.nz>
|
||||||
|
|
||||||
|
* java/net/natPlainSocketImplPosix.cc (connect): Pass the FD as a
|
||||||
|
ready-to-write argument to _Jv_Select. Reset the socket back to
|
||||||
|
non-blocking state after connecting.
|
||||||
|
(accept): Pass the FD as a ready-to-write argument to _Jv_Select.
|
||||||
|
Throw SocketTimeoutException not InterruptedIOException.
|
||||||
|
(read): Throw SocketTimeoutException not InterruptedIOException.
|
||||||
|
|
||||||
2003-08-07 Bryce McKinlay <bryce@mckinlay.net.nz>
|
2003-08-07 Bryce McKinlay <bryce@mckinlay.net.nz>
|
||||||
|
|
||||||
* java/lang/Thread.java (Thread): Check for null "name" from
|
* java/lang/Thread.java (Thread): Check for null "name" from
|
||||||
|
|
|
@ -174,19 +174,21 @@ java::net::PlainSocketImpl::connect (java::net::SocketAddress *addr,
|
||||||
if ((_Jv_connect (fnum, ptr, len) != 0) && (errno != EINPROGRESS))
|
if ((_Jv_connect (fnum, ptr, len) != 0) && (errno != EINPROGRESS))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
fd_set rset;
|
fd_set fset;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
FD_ZERO(&rset);
|
FD_ZERO(&fset);
|
||||||
FD_SET(fnum, &rset);
|
FD_SET(fnum, &fset);
|
||||||
tv.tv_sec = timeout / 1000;
|
tv.tv_sec = timeout / 1000;
|
||||||
tv.tv_usec = (timeout % 1000) * 1000;
|
tv.tv_usec = (timeout % 1000) * 1000;
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
if ((retval = _Jv_select (fnum + 1, &rset, NULL, NULL, &tv)) < 0)
|
if ((retval = _Jv_select (fnum + 1, &fset, &fset, NULL, &tv)) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
else if (retval == 0)
|
else if (retval == 0)
|
||||||
throw new java::net::SocketTimeoutException
|
throw new java::net::SocketTimeoutException
|
||||||
(JvNewStringUTF ("Connect timed out"));
|
(JvNewStringUTF ("Connect timed out"));
|
||||||
|
// Set the socket back into a blocking state.
|
||||||
|
::fcntl (fnum, F_SETFL, flags);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -233,17 +235,17 @@ java::net::PlainSocketImpl::accept (java::net::PlainSocketImpl *s)
|
||||||
// Do timeouts via select since SO_RCVTIMEO is not always available.
|
// Do timeouts via select since SO_RCVTIMEO is not always available.
|
||||||
if (timeout > 0 && fnum >= 0 && fnum < FD_SETSIZE)
|
if (timeout > 0 && fnum >= 0 && fnum < FD_SETSIZE)
|
||||||
{
|
{
|
||||||
fd_set rset;
|
fd_set fset;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
FD_ZERO(&rset);
|
FD_ZERO(&fset);
|
||||||
FD_SET(fnum, &rset);
|
FD_SET(fnum, &fset);
|
||||||
tv.tv_sec = timeout / 1000;
|
tv.tv_sec = timeout / 1000;
|
||||||
tv.tv_usec = (timeout % 1000) * 1000;
|
tv.tv_usec = (timeout % 1000) * 1000;
|
||||||
int retval;
|
int retval;
|
||||||
if ((retval = _Jv_select (fnum + 1, &rset, NULL, NULL, &tv)) < 0)
|
if ((retval = _Jv_select (fnum + 1, &fset, &fset, NULL, &tv)) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
else if (retval == 0)
|
else if (retval == 0)
|
||||||
throw new java::io::InterruptedIOException (
|
throw new java::net::SocketTimeoutException (
|
||||||
JvNewStringUTF("Accept timed out"));
|
JvNewStringUTF("Accept timed out"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,7 +404,7 @@ java::net::PlainSocketImpl::read(void)
|
||||||
// If select returns 0 we've waited without getting data...
|
// If select returns 0 we've waited without getting data...
|
||||||
// that means we've timed out.
|
// that means we've timed out.
|
||||||
if (sel_retval == 0)
|
if (sel_retval == 0)
|
||||||
throw new java::io::InterruptedIOException
|
throw new java::net::SocketTimeoutException
|
||||||
(JvNewStringUTF ("read timed out") );
|
(JvNewStringUTF ("read timed out") );
|
||||||
// If select returns ok we know we either got signalled or read some data...
|
// If select returns ok we know we either got signalled or read some data...
|
||||||
// either way we need to try to read.
|
// either way we need to try to read.
|
||||||
|
@ -467,11 +469,10 @@ java::net::PlainSocketImpl::read(jbyteArray buffer, jint offset, jint count)
|
||||||
// the socket to see what happened.
|
// the socket to see what happened.
|
||||||
if (sel_retval == 0)
|
if (sel_retval == 0)
|
||||||
{
|
{
|
||||||
java::io::InterruptedIOException *iioe =
|
java::net::SocketTimeoutException *timeoutException =
|
||||||
new java::io::InterruptedIOException
|
new java::net::SocketTimeoutException
|
||||||
(JvNewStringUTF ("read interrupted"));
|
(JvNewStringUTF ("read timed out"));
|
||||||
iioe->bytesTransferred = 0;
|
throw timeoutException;
|
||||||
throw iioe;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue