[kaffe] gnu.java.nio.VMSelector implementation

Guilhem Lavaux guilhem at kaffe.org
Sun Apr 3 07:54:08 PDT 2005


On Sun, 2005-04-03 at 12:28 +0200, Michael Koch wrote:
> On Sun, Apr 03, 2005 at 05:04:32PM +0900, Rei Odaira wrote:
> > --- libraries/clib/nio/gnu_java_nio_VMSelector.c	1 Apr 2005 01:02:56 -0000	1.5
> > +++ libraries/clib/nio/gnu_java_nio_VMSelector.c	3 Apr 2005 07:24:27 -0000
> > @@ -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,
> 
> Why do you do these? Using cryptic values withoud documenting it is at
> least not good for maintaining the code? What does the -2 stands for?
> We should use constant names wherever possible to make it easier to port
> the code to other archs. E.g. On my Linux EINTR has the value "4" and
> not "-2". So this change looks just plain wrong for Linux.
> 
> 

Hi Michael,

You are right. We should not use raw integer value in the middle of the
code. However VMSelector should not use positive values to return an
interrupt event as it may be misunderstood in some circumstances when
you are only selecting on 4 descriptors (and then EINTR==4 :( ). I have
slightly modified the patch to use negative integer values to return
error code in kaffe. At the same time I've noticed that select0 was
using errno to check the error code (which is not right in our jthread
paradigm). This should be fixed now.

Regards,

Guilhem.





More information about the kaffe mailing list