PatchSet 5650 
Date: 2005/04/03 11:24:04
Author: guilhem
Branch: HEAD
Tag: (none) 
Log:
Fixes for selectable channel.

2005-04-03  Rei Odaira <[EMAIL PROTECTED]>

        * kaffe/kaffevm/systems/unix-jthreads/jthread.c
        (jthreadedSelect): Fixed timeout handling, fdset handling. maxFd,
        readsPending, writesPending updated properly.

        * libraries/clib/nio/gnu_java_nio_VMSelector.c
        (helper_select, select0): Use a negative value to avoid confusion
        between the number of filedescriptor and the error value returned
        by select.

        * libraries/javalib/java/nio/channels/spi/AbstractSelectableChannel.java
        (register): Check for blocking state.

Members: 
        ChangeLog:1.3820->1.3821 
        kaffe/kaffevm/systems/unix-jthreads/jthread.c:1.131->1.132 
        libraries/clib/nio/gnu_java_nio_VMSelector.c:1.5->1.6 
        
libraries/javalib/java/nio/channels/spi/AbstractSelectableChannel.java:1.11->1.12
 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.3820 kaffe/ChangeLog:1.3821
--- kaffe/ChangeLog:1.3820      Sun Apr  3 00:51:21 2005
+++ kaffe/ChangeLog     Sun Apr  3 11:24:04 2005
@@ -1,3 +1,17 @@
+2005-04-03  Rei Odaira <[EMAIL PROTECTED]>
+
+       * kaffe/kaffevm/systems/unix-jthreads/jthread.c
+       (jthreadedSelect): Fixed timeout handling, fdset handling. maxFd,
+       readsPending, writesPending updated properly.
+
+       * libraries/clib/nio/gnu_java_nio_VMSelector.c
+       (helper_select, select0): Use a negative value to avoid confusion
+       between the number of filedescriptor and the error value returned
+       by select.
+
+       * libraries/javalib/java/nio/channels/spi/AbstractSelectableChannel.java
+       (register): Check for blocking state.
+
 2005-04-03  Dalibor Topic  <[EMAIL PROTECTED]>
 
        * kaffe/kaffevm/systems/unix-pthreads/Makefile.am 
Index: kaffe/kaffe/kaffevm/systems/unix-jthreads/jthread.c
diff -u kaffe/kaffe/kaffevm/systems/unix-jthreads/jthread.c:1.131 
kaffe/kaffe/kaffevm/systems/unix-jthreads/jthread.c:1.132
--- kaffe/kaffe/kaffevm/systems/unix-jthreads/jthread.c:1.131   Sat Apr  2 
17:44:45 2005
+++ kaffe/kaffe/kaffevm/systems/unix-jthreads/jthread.c Sun Apr  3 11:24:08 2005
@@ -3325,29 +3325,64 @@
        tval.tv_sec = 0;
        tval.tv_usec = 0;
 
-       time_milli = e->tv_usec / 1000 + e->tv_sec * 1000;
+       if (e != NULL)
+               time_milli = e->tv_usec / 1000 + e->tv_sec * 1000;
+       else
+               time_milli = NOTIMEOUT;
 
        intsDisable();
 
        for (;;) {
-               if ((*out = select(a, b, c, d, &tval)) == -1) {
+               fd_set tmp_b, tmp_c, tmp_d;
+
+               FD_COPY(b, &tmp_b);
+               FD_COPY(c, &tmp_c);
+               FD_COPY(d, &tmp_d);
+
+               if ((*out = select(a, &tmp_b, &tmp_c, &tmp_d, &tval)) == -1) {
                        rc = errno;
                        break;
                }
-               if ((*out == 0 && second_time) || *out != 0)
+               if ((*out == 0 && second_time) || *out != 0) {
+                       FD_COPY(&tmp_b, b);
+                       FD_COPY(&tmp_c, c);
+                       FD_COPY(&tmp_d, d);
                        break;
+               }
 
                if (time_milli != 0) {
+                       int interrupted;
+
+                       BLOCKED_ON_EXTERNAL(currentJThread);
+
+                       if (a - 1 > maxFd)
+                               maxFd = a - 1;
+
                        for (i=0;i<a;i++) {
-                               if (b && FD_ISSET(i, b))
+                               if (b && FD_ISSET(i, b)) {
+                                       FD_SET(i, &readsPending);
                                        addWaitQThread(currentJThread, 
&readQ[i]);
-                               if (c && FD_ISSET(i, c))
+                               }
+                               if (c && FD_ISSET(i, c)) {
+                                       FD_SET(i, &writesPending);
                                        addWaitQThread(currentJThread, 
&writeQ[i]);
+                               }
                        }
 
-                       if (suspendOnQThread(currentJThread, NULL, time_milli)) 
{
+                       interrupted = suspendOnQThread(currentJThread, NULL, 
time_milli);
+
+                       for (i=0;i<a;i++) {
+                               if (b && FD_ISSET(i, b))
+                                       FD_CLR(i, &readsPending);
+                               if (c && FD_ISSET(i, c))
+                                       FD_CLR(i, &writesPending);
+                       }
+                       if (interrupted) {
                                rc = EINTR;
                                *out = 0;
+                               FD_ZERO(b);
+                               FD_ZERO(c);
+                               FD_ZERO(d);
                                break;
                        }
                }
Index: kaffe/libraries/clib/nio/gnu_java_nio_VMSelector.c
diff -u kaffe/libraries/clib/nio/gnu_java_nio_VMSelector.c:1.5 
kaffe/libraries/clib/nio/gnu_java_nio_VMSelector.c:1.6
--- kaffe/libraries/clib/nio/gnu_java_nio_VMSelector.c:1.5      Fri Apr  1 
01:02:56 2005
+++ kaffe/libraries/clib/nio/gnu_java_nio_VMSelector.c  Sun Apr  3 11:24:08 2005
@@ -166,7 +166,7 @@
                /* Here we know we got EINTR. */
                if ( (*env)->CallStaticBooleanMethod(env, thread_class, 
thread_interrupted) )
                {
-                       return EINTR;
+                       return -2;
                }
 
                if (timeout)
@@ -249,7 +249,7 @@
        result = helper_select (env, thread_class, thread_interrupted, max_fd + 
1, &read_fds, &write_fds,
                                                                &except_fds, 
time_data);
 
-       if( result == EINTR ) {
+       if( result == -2 ) {
                /* The behavior of JRE 1.4.1 is that no exception is thrown
                 * when the thread is interrupted, but the thread's interrupt
                 * status is set. Clear all of our select sets and return 0,
Index: 
kaffe/libraries/javalib/java/nio/channels/spi/AbstractSelectableChannel.java
diff -u 
kaffe/libraries/javalib/java/nio/channels/spi/AbstractSelectableChannel.java:1.11
 
kaffe/libraries/javalib/java/nio/channels/spi/AbstractSelectableChannel.java:1.12
--- 
kaffe/libraries/javalib/java/nio/channels/spi/AbstractSelectableChannel.java:1.11
   Fri Dec  3 00:44:29 2004
+++ 
kaffe/libraries/javalib/java/nio/channels/spi/AbstractSelectableChannel.java    
    Sun Apr  3 11:24:09 2005
@@ -43,6 +43,7 @@
 import java.nio.channels.SelectableChannel;
 import java.nio.channels.SelectionKey;
 import java.nio.channels.Selector;
+import java.nio.channels.IllegalBlockingModeException;
 import java.util.LinkedList;
 import java.util.ListIterator;
 
@@ -224,6 +225,9 @@
 
     synchronized (blockingLock())
       {
+       if (blocking)
+         throw new IllegalBlockingModeException();
+
        key = locate(selector);
 
        if (key != null && key.isValid())

_______________________________________________
kaffe mailing list
[email protected]
http://kaffe.org/cgi-bin/mailman/listinfo/kaffe

Reply via email to