AnyEvent and Strawberry perl issue
Dirk Koopman
djk at tobit.co.uk
Fri Mar 13 11:25:53 CET 2015
On 13/03/15 07:33, Marc Lehmann wrote:
> On Wed, Mar 11, 2015 at 05:35:17PM -0400, Laurent <laurent.aml at gmail.com> wrote:
>> Apparently, in my setup of Strawberry Perl 5.20, syswrite reports
>> POSIX::EWOULDBLOCK (140) instead of the WSAEWOULDBLOCK (10035) or EAGAIN.
>> In particular, this makes the readline test fail:
>
> The pain. It never ends.
>
> Anyway, thanks for bringing this to my attention, I had no idea.
>
> This is yet another idiotic bug in perl - the corresponding error code for
> WSAEWOULDBLOCK would be EAGAIN (35), the winsock error codes are generally
> shifted by 10000. This change breaks not only existing perl programs
> (which makes it idiotic), but also most unix programs (which use EAGAIN,
> as EWOULDBLOCK is virtually unused on unix for this).
>
This is nothing new, and not confined to Strawberry Perl. ActiveState
also had this problem from 5.004 onwards. So I have resorted to this
sort of nonsense in the past:
unless ($^O eq 'MSWin32') {
if ($] >= 5.6) {
eval {
local $^W;
require Socket; Socket->import(qw(IPPROTO_TCP
TCP_NODELAY));
};
} else {
dbg("IPPROTO_TCP and TCP_NODELAY manually defined");
eval 'sub IPPROTO_TCP { 6 };';
eval 'sub TCP_NODELAY { 1 };';
}
}
# http://support.microsoft.com/support/kb/articles/Q150/5/37.asp
# defines EINPROGRESS as 10035. We provide it here because some
# Win32 users report POSIX::EINPROGRESS is not vendor-supported.
if ($^O eq 'MSWin32') {
eval '*EINPROGRESS = sub { 10036 };' unless defined *EINPROGRESS;
eval '*EWOULDBLOCK = *EAGAIN = sub { 10035 };' unless defined
*EWOULDBLOCK;
eval '*F_GETFL = sub { 0 };' unless defined *F_GETFL;
eval '*F_SETFL = sub { 0 };' unless defined *F_SETFL;
eval 'sub IPPROTO_TCP { 6 };';
eval 'sub TCP_NODELAY { 1 };';
$blocking_supported = 0; # it appears that this DOESN'T work :-(
}
Git blame tells that this has been in a piece of non-AE code since 2002.
Still works perfectly happily on all known M$ perls.
Dirk
Dirk
More information about the anyevent
mailing list