AnyEvent and Strawberry perl issue

Marc Lehmann schmorp at schmorp.de
Fri Mar 13 15:50:09 CET 2015


On Fri, Mar 13, 2015 at 10:25:53AM +0000, Dirk Koopman <djk at tobit.co.uk> wrote:
> 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:

The problem is that your "nonsense" unfortunately also doesn't work:

>         eval '*EINPROGRESS = sub { 10036 };' unless defined *EINPROGRESS;

EINPROGRESS and windows' 10036 (I assume that is WSAEINPROGRESS) have no
overlapping meaning. For example, when you get 10036 on connect, it means
"connect failed, nothing further will happen" while EINPROGRESS means
"connect is on its way, we will notify you when it's done".

I don't think there is a single case where EINPROGRESS and WSAEINPROGRESS
mean the same thing. They are simply completely different error codes, and
treating them the same leads to rare and thus hard to track down bugs.

> 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.

Well, either the code wasn't exercised much, didn't use EINPROGRESS or was
just lucky - AnyEvent gets used a lot, and did run into the problem of
WSAEINPROGRESS not meaning EINPROGRESS: while developing AnyEvent::Socket,
I assumed they are the same, and that caused hanging connects. Workaround
was easy, as the codes are distinct on windows (but no longer are in perl
apparently).

So this perl problem effectively tricked you into a bug in your code,
whether you ran into it or not.

Working around this is hard now, as I would effectively do some fragile
perl version + platform check to somehow invalidate perl's incorrect
EINPROGRESS.

I would say that using EWOULDBLOCK when every other os(*) uses only
EAGAIN would be merely a problem, a nuisance, and one might wonder why
perl wanted to be different than any other platform, but conflating
completely independent error codes such as WSAEINPROGRESS and EINPROGRESS
is completely uncalled for and causes perl users to assume they mena
the same, leading to hidden bugs. All of which would be completely
unnecessary.

The problem of perl is not that sometimes bugs happen. The problem of
perl is that there are so many uncalled-for and completely unnecessary
changes that nobody researched, tested, verified, thought about, had a
valid rationale etc. perl5porters live in a world where no code exists and
breaking things is of no concern. That simply has to stop: ever since these
new backwards-compatibility-who-cares rules are in place all the perl books
vanished from my local bookstores. Who would care about a programming
language that is continuously being broken - you can't code in it.

(*) you have to go back over a decade to find an OS which even had
    different values for those two macros, and further even to find an OS
    which actively issued both. There might not ever even have been an os
    where EAGAIN was available but didn't work. Until perl invented
    one.

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at schmorp.de
      -=====/_/_//_/\_,_/ /_/\_\



More information about the anyevent mailing list