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
|