Menu

#751 poll gives WSAEINVAL when POLLPRI is set in fdset.events

closed-fixed
libcurl (356)
5
2014-07-19
2008-07-10
No

Hi

curl version: 7.18.2

Tried to build curl on VS 2005.
Single easy http fetch fails with CURLE_GOT_NOTHING.

Setting following in setup.h fixes the problem:
#undef POLLPRI
#define POLLPRI 0

The build uses Winsock 2.

The problem seems to be in Curl_socket_ready function.
Function sets POLLPRI bit to pollfd events field.

The POLLPRI seems to have value 0x0400 at least
in Windows platform sdk header winsock2.h.

poll (WSAPoll) then returns WSAEINVAL.

According to following page, POLLPRI is not among values for events field:
http://msdn.microsoft.com/en-us/library/ms740094\(VS.85).aspx

My guess is that some windows update
added error checks that don't like POLLPRI.
Another possibility is that versions of the header files
have different values for POLLPRI.

Hope this helps...
Thanks for the cool software.

Discussion

  • Yang Tse

    Yang Tse - 2008-07-10

    Logged In: YES
    user_id=1590006
    Originator: NO

    Yes, MS maps priority (out-of-band) data to POLLRDBAND.

    Can you verify if this patch works for you ?

    Index: select.h

    RCS file: /cvsroot/curl/curl/lib/select.h,v
    retrieving revision 1.15
    diff -u -r1.15 select.h
    --- select.h 22 Jan 2008 14:52:54 -0000 1.15
    +++ select.h 10 Jul 2008 16:30:20 -0000
    @@ -43,6 +43,8 @@
    #define HAVE_POLL_FINE 1
    #define poll(x,y,z) WSAPoll((x),(y),(z))
    #if defined(_MSC_VER) && defined(POLLRDNORM)
    +#undef POLLPRI
    +#define POLLPRI POLLRDBAND
    #define HAVE_STRUCT_POLLFD 1
    #endif
    #endif

     
  • Yang Tse

    Yang Tse - 2008-07-10

    Logged In: YES
    user_id=1590006
    Originator: NO

    Yes, MS maps priority (out-of-band) data to POLLRDBAND.

    Can you verify if this patch works for you ?

    Index: select.h

    RCS file: /cvsroot/curl/curl/lib/select.h,v
    retrieving revision 1.15
    diff -u -r1.15 select.h
    --- select.h 22 Jan 2008 14:52:54 -0000 1.15
    +++ select.h 10 Jul 2008 16:30:20 -0000
    @@ -43,6 +43,8 @@
    #define HAVE_POLL_FINE 1
    #define poll(x,y,z) WSAPoll((x),(y),(z))
    #if defined(_MSC_VER) && defined(POLLRDNORM)
    +#undef POLLPRI
    +#define POLLPRI POLLRDBAND
    #define HAVE_STRUCT_POLLFD 1
    #endif
    #endif

     
  • Peter Lamberg

    Peter Lamberg - 2008-07-10

    Logged In: YES
    user_id=116239
    Originator: YES

    Yup. The patch works. Thanks!

     
  • Yang Tse

    Yang Tse - 2008-07-10

    Logged In: YES
    user_id=1590006
    Originator: NO

    Patch committed to CVS now. Daily snapshot dated July 11 2008 or later will have the fix.
    http://cool.haxx.se/curl-daily/

    My thanks and applause goes to you Peter. Bug reports with this level of previous work for Windows are quite uncommon.

    Cheers

     
  • Daniel Stenberg

    Daniel Stenberg - 2008-07-10

    Logged In: YES
    user_id=1110
    Originator: NO

    Great report. Fastly received and committed. Thanks. Case closed!

     
  • Daniel Stenberg

    Daniel Stenberg - 2008-07-10
    • status: open --> closed-fixed