invalid win32 accept() check in ev_pipe

Vladimir Ivannikov v.ivannikov at gaijin.ru
Thu Nov 12 16:35:04 CET 2015



12.11.2015 10:03, Marc Lehmann пишет:
> On Tue, Nov 10, 2015 at 11:28:26PM +0300, Vladimir Ivannikov <v.ivannikov at gaijin.ru> wrote:
>> There is tiny bug in win32 implementation of ev_pipe() caused by the fact
>> that accept() returns SOCKET type which is actually UINT_PTR on windows
>> which of couse unsigned and can't be
>> signed compared with 0 (compiler will just optimized this check out)
>> Patch is trivial:
> Hi, thanks for your interest!
>
> Your analysis is correct and the patch is trivial, but of course breaks
> this libev when accept returns a file descriptor (not all accept
> implementations return handles).
AFAICT code in question is resides in ev_win32.c under ifdef _WIN32, 
which makes it strictly win32-specific.
And even if it didn't, accept() returns not any negative value on error, 
but -1 which is also happens to be INVALID_SOCKET value as well (which 
is also win32-specific define, but usually emulated via something like
#define INVALID_SOCKET (-1)
on other platforms)
>   Since optimising the check out shouldn't
> cause an issue either, it's not even a bug, and thus, I'd probably just
> leave it as is for the moment, as the code seems correct as it stands, and
> probably will remove error chekcing altogether in that place.
>




More information about the libev mailing list