faster.rb should handle Errno::EAGAIN #12

Closed
alwyn opened this Issue Jan 12, 2012 · 8 comments

Projects

None yet

2 participants

alwyn commented Jan 12, 2012

The non-blocking io implementations of ruby and jruby throw EAGAIN when there is no data to be read.

faster.rb should handle EAGAIN in the same manner as it is currently handling EWOULDBLOCK to resolve the issue. I've looked at the original patch and it did contain EAGAIN.

Owner
drbrain commented Jan 31, 2012

EAGAIN and EWOULDBLOCK are the same object. You will need to file a ticket against jruby if they are not:

$ multiruby -e 'p Errno::EWOULDBLOCK.equal? Errno::EAGAIN'

VERSION = 1.8.7-p330
CMD     = ~/.multiruby/install/1.8.7-p330/bin/ruby -e p Errno::EWOULDBLOCK.equal? Errno::EAGAIN

true

RESULT = 0

VERSION = 1.9.2-p290
CMD     = ~/.multiruby/install/1.9.2-p290/bin/ruby -e p Errno::EWOULDBLOCK.equal? Errno::EAGAIN

true

RESULT = 0

VERSION = 1.9.3-p0
CMD     = ~/.multiruby/install/1.9.3-p0/bin/ruby -e p Errno::EWOULDBLOCK.equal? Errno::EAGAIN

true

RESULT = 0

TOTAL RESULT = 0 failures out of 3

Passed: 1.9.3-p0, 1.9.2-p290, 1.8.7-p330
Failed: 

Also sys/errno.h on OS X:

$ grep EAGAIN /usr/include/sys/errno.h
                    /* 11 was EAGAIN */
#define EAGAIN      35      /* Resource temporarily unavailable */
#define EWOULDBLOCK EAGAIN      /* Operation would block */

and FreeBSD:

$ grep EAGAIN /usr/include/sys/errno.h 
                                        /* 11 was EAGAIN */
#define EAGAIN          35              /* Resource temporarily unavailable */
#define EWOULDBLOCK     EAGAIN          /* Operation would block */

Linux 2.6: http://fxr.watson.org/fxr/source/include/asm-generic/errno.h?v=linux-2.6#L12

@drbrain drbrain closed this Jan 31, 2012
Owner
drbrain commented Jan 31, 2012

It seems that they are equal even on the latest jruby:

$ jruby -ve 'p Errno::EAGAIN.equal? Errno::EWOULDBLOCK'
jruby 1.6.6 (ruby-1.8.7-p357) (2012-01-30 5673572) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_29) [darwin-x86_64-java]
true
alwyn commented Feb 1, 2012

Just tested it on jruby 1.6.5.1 and it still failed there, so 1.6.6 must be a fix for the problem. Thanks

alwyn commented Feb 1, 2012

Ok interesting problem.

It would appear that on Windows even with jruby-1.6.6 it still returns false:

C:\Users\aschoema>jruby -ve 'p Errno::EAGAIN.equal? Errno::EWOULDBLOCK'
jruby 1.6.6 (ruby-1.8.7-p357) (2012-01-30 5673572) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_25) [Windows 7-amd64-java]
false

Same case after upgrading to Java 1.6.0_30.

So it would appear that the issue here is with Windows headers for compilers.

@drbrain drbrain reopened this Feb 1, 2012
Owner
drbrain commented Feb 1, 2012

On C Ruby on windows does EAGAIN equal EWOULDBLOCK?

Looking through the C Ruby source code, it appears that there is a platform where they are not equal, perhaps Windows makes a distinction?

alwyn commented Feb 5, 2012

Yes it is windows, not sure if it is set in winsock or some other windows api...

@drbrain drbrain closed this in 232f975 Feb 6, 2012
Owner
drbrain commented Feb 6, 2012

Thanks for your patience in this matter!

alwyn commented Feb 9, 2012

No problem, if it wasn't for my current job I wouldn't care about windows :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment