JDK-5100121 : (se) select not immune to EINTR
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 9.1ee,1.4.2_05,6
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS:
    linux_2.6,linux_redhat_2.1,solaris_9,solaris_10 linux_2.6,linux_redhat_2.1,solaris_9,solaris_10
  • CPU: generic,x86,sparc
  • Submitted: 2004-09-10
  • Updated: 2008-06-20
  • Resolved: 2004-11-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other Other Other Other Other JDK 6
1.4.2_07 b02Fixed 1.4.2_19-revFixed 1.4.2_21Fixed 5.0u17-revFixed 5.0u19Fixed 6Fixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Description
One of Java developer hits one case of BugID#4504001.
It's sun.nio.ch.SelectorImpl.select case.

  BugID#4504001 Check NIO native code to ensure that it restarts any sys calls

The information for the environment and stack trace are below.

====== message =========================================================
[Env]
 JDK version: J2EE1.4.2_05
 JAVA option: -server
 Operating System : RedHat Linux Advanced Server

[Stacktrace at the IOException]

 2004-08-16 20:27:25,931 [ERROR] java.io.IOException: Interrupted system call
 at sun.nio.ch.PollArrayWrapper.poll0(Native Method)
 at sun.nio.ch.PollArrayWrapper.poll(PollArrayWrapper.java:100)
 at sun.nio.ch.PollSelectorImpl.doSelect(PollSelectorImpl.java:64)
 at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:59)
 at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:70)
 at 
jp.co.nttcom.raspberry.integration.systemconnection.inbound.socket.SocketEisInbo
undAccepter.run(SocketEisInboundAccepter.java:292)
(jp.co.nttcom.raspberry.integration.systemconnection.inbound.socket.SocketEisInb
oundAccepter)
======================================================================
###@###.### 10/6/04 21:41 GMT

Comments
EVALUATION Although the bug was reported against Linux, the issue also exists on Solaris. When this fix is forward ported to mustang it needs to address the issue for Solaris too.
09-11-2005

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.4.2_07 1.5.0_01 FIXED IN: 1.4.2_07 1.5.0_01
02-10-2004

SUGGESTED FIX *** src/solaris/native/sun/nio/ch/PollArrayWrapper.c- Mon Sep 27 11:29:41 2004 --- PollArrayWrapper.c Mon Sep 27 11:22:33 2004 *** 9,30 **** #include "jni_util.h" #include "jvm.h" #include "jlong.h" #include "sun_nio_ch_PollArrayWrapper.h" #include <poll.h> JNIEXPORT jint JNICALL Java_sun_nio_ch_PollArrayWrapper_poll0(JNIEnv *env, jobject this, jlong address, jint numfds, jlong timeout) { struct pollfd *a; int err = 0; a = (struct pollfd *) jlong_to_ptr(address); ! err = poll(a, numfds, timeout); if (err < 0) JNU_ThrowIOExceptionWithLastError(env, "Poll failed"); return (jint)err; } --- 9,58 ---- #include "jni_util.h" #include "jvm.h" #include "jlong.h" #include "sun_nio_ch_PollArrayWrapper.h" #include <poll.h> + #include <unistd.h> + #include <sys/time.h> + static jint + ipoll(struct pollfd fds[], unsigned int nfds, int timeout) + { + jlong start, now; + jlong remaining = timeout; + struct timeval t; + gettimeofday(&t, NULL); + start = t.tv_sec * 1000 + t.tv_usec / 1000; + + for (;;) { + int res = poll(fds, nfds, remaining); + if (res < 0 && errno == EINTR) { + if (remaining >= 0) { + gettimeofday(&t, NULL); + now = t.tv_sec * 1000 + t.tv_usec / 1000; + remaining -= now - start; + if (remaining <= 0) + return 0; + start = now; + } + } else { + return res; + } + } + } + JNIEXPORT jint JNICALL Java_sun_nio_ch_PollArrayWrapper_poll0(JNIEnv *env, jobject this, jlong address, jint numfds, jlong timeout) { struct pollfd *a; int err = 0; a = (struct pollfd *) jlong_to_ptr(address); ! err = ipoll(a, numfds, timeout); if (err < 0) JNU_ThrowIOExceptionWithLastError(env, "Poll failed"); return (jint)err; } ###@###.### 2004-09-27
27-09-2004

EVALUATION Restart poll after interruption. ###@###.### 2004-09-24
24-09-2004