Menu

#635 Bug in new tcp_select() function in Windows (2.7.14)

closed-fixed
None
5
2010-04-06
2009-10-02
No

The newly added tcp_select() function in version 2.7.14 break windows functionality because of the following check:
stdsoap2.cpp line 4353: if ((int)s >= (int)FD_SETSIZE)

The above check is only valid on BSD-based systems that implement fd_set struct passed to select() as a bit-array and FD_SET macro sets the appropriate bit in the bit-array. In windows, this is implemented differently. fd_set struct is actually an array of sockets with an fd_count which counts how many elements in the socket array exist. The FD_SETSIZE only determines maximum number of sockets that can be passed in as argument to each select() call and since soap only passes one socket in, as long as FD_SETSIZE is greater than zero, there should be no problem in calling select().

Previous version of soap used to not do this check if WIN32 was defined but this check doesn't exist in 2.7.14 in the newly created tcp_select() function.

Discussion

  • Sina Afrooze

    Sina Afrooze - 2009-10-02
    • priority: 5 --> 9
     
  • Sina Afrooze

    Sina Afrooze - 2009-10-02
    • summary: new tcp_select() function doesn't work on Windows (2.7.14) --> Bug in new tcp_select() function in Windows (2.7.14)
     
  • sldr

    sldr - 2009-10-08

    The following snippit fixes the problem:
    static int
    tcp_select(struct soap *soap, SOAP_SOCKET s, int flags, int timeout)
    { register int r;
    struct timeval tv;
    fd_set fd[3], *rfd, *sfd, *efd;
    soap->errnum = 0;
    /* if fd max set size exceeded, use poll() when available */
    #if defined(__QNX__) || defined(QNX) /* select() is not MT safe on some QNX */
    if (1)
    #elif defined(WIN32)
    if (0)
    #else
    if ((int)s >= (int)FD_SETSIZE)
    #endif

     
  • Robert van Engelen

    A poll() should work on Win32. I guess the HAVE_POLL is not set in stdsoap2.h or config.h to allow poll(). Adding a simple #ifdef WIN32 in stdsoap2.cpp to hardcode circumvent the FD_EXCEEDED check is fine too.

     
  • Robert van Engelen

    • priority: 9 --> 5
     
  • sldr

    sldr - 2009-10-12

    Windows does not have a poll() function. The HAVE_POLL should not be set on windows.

     
  • Robert van Engelen

    • assigned_to: nobody --> engelen
    • status: open --> open-fixed
     
  • Robert van Engelen

    • status: open-fixed --> closed-fixed
     

Log in to post a comment.