Subject: Select (function _libssh2_wait_socket) issue on some on an embedded platform

Select (function _libssh2_wait_socket) issue on some on an embedded platform

From: Sebastien Fricker <Sebastien.Fricker_at_ipetronik.com>
Date: Fri, 26 Mar 2010 11:54:25 +0100

Hi,
we have found an issue on a real-time OS (here RTOS-32 from OnTime)
about the usage of select.

In the function _libssh_wait_socket select is used with 2 pointer of
descriptors: readfd and writefd.
This pointers are pointing to the same fd_set.
On RTOS32, this causes an error.

If readfd and writefd are pointing to 2 different variables, select
works well.

In this case the modified code would be:
int _libssh2_wait_socket(LIBSSH2_SESSION *session)
{
    fd_set fd_read;
    fd_set fd_write;
    fd_set *writefd = NULL;
    fd_set *readfd = NULL;
    int dir;
    int rc;

    FD_ZERO(&fd_read);
    FD_SET(session->socket_fd, &fd_read);
    FD_ZERO(&fd_write);
    FD_SET(session->socket_fd, &fd_write);

    /* now make sure we wait in the correct direction */
    dir = libssh2_session_block_directions(session);

    if(dir & LIBSSH2_SESSION_BLOCK_INBOUND)
        readfd = &fd_read;

    if(dir & LIBSSH2_SESSION_BLOCK_OUTBOUND)
        writefd = &fd_write;

  .....

The modification should not create any regression to libssh2, and if
nobody are seeing any problem about this code, I will provide a patch.
Regards
Sébastien

-- 
------------------------------------------------------------
Ipetronik GmbH & Co.KG
Jaegerweg 1
D-76532 Baden-Baden
 
Phone-No. +49 - (0)7221/9922-467
Fax-No. +49 - (0)7221/9922-153
 
mailto: sebastien.fricker_at_ipetronik.com
web: http://www.ipetronik.com 
 
------------------------------------------------------------
Kommanditgesellschaft mit Sitz in Baden-Baden, Registergericht HRA
Nr.201313
Persoenlich haftende Gesellschaft ist die IPETRONIK Verwaltungs GmbH 
mit Sitz in Baden-Baden, Registergericht Mannheim HRB Nr.202089, 
Geschäftsführer: J.Abromeit, E.Rudolf, A. Wocke
-------------------------------------------------------------
 
 
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-03-26