[9] RFR of 8132652: Java_sun_nio_ch_Net_poll passes a long to an int
Brian Burkhalter
brian.burkhalter at oracle.com
Mon Aug 3 18:54:45 UTC 2015
On Aug 3, 2015, at 10:44 AM, Brian Burkhalter <brian.burkhalter at oracle.com> wrote:
>> This looks okay. A slight variant would be to set timeout to -1 then any negative value means an infinite timeout to the poll syscall.
>
> Good point as the specifications vary.
I wonder whether there is a separate problem with the Windows variant for the case of timeout < 0. According to the MSDN documentation of select(), [1]:
timeout [in]
The maximum time for select to wait, provided in the form of a TIMEVAL structure. Set the timeout parameter to null for blocking operations.
--- a/src/java.base/windows/native/libnio/ch/Net.c
+++ b/src/java.base/windows/native/libnio/ch/Net.c
@@ -561,34 +561,36 @@
Java_sun_nio_ch_Net_poll(JNIEnv* env, jclass this, jobject fdo, jint events, jlong timeout)
{
int rv;
int revents = 0;
struct timeval t;
int lastError = 0;
fd_set rd, wr, ex;
jint fd = fdval(env, fdo);
- t.tv_sec = timeout / 1000;
- t.tv_usec = (timeout % 1000) * 1000;
+ if (timeout >= 0) {
+ t.tv_sec = timeout / 1000;
+ t.tv_usec = (timeout % 1000) * 1000;
+ }
FD_ZERO(&rd);
FD_ZERO(&wr);
FD_ZERO(&ex);
if (events & POLLIN) {
FD_SET(fd, &rd);
}
if (events & POLLOUT ||
events & POLLCONN) {
FD_SET(fd, &wr);
}
FD_SET(fd, &ex);
- rv = select(fd+1, &rd, &wr, &ex, &t);
+ rv = select(fd+1, &rd, &wr, &ex, timeout >= 0 ? &t : NULL);
If this looks worth addressing I can file a separate issue.
Brian
[1] https://msdn.microsoft.com/en-us/library/windows/desktop/ms740141%28v=vs.85%29.aspx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20150803/ce5ac99d/attachment.html>
More information about the nio-dev
mailing list