Subject: Setting timeout in blocking mode

Setting timeout in blocking mode

From: Sebastien Fricker <Sebastien.Fricker_at_ipetronik.com>
Date: Tue, 09 Mar 2010 11:00:52 +0100

Hi,
I'm currently wondering why there is now wait so specify a timeout when
working on blocking mode.

If we have a look on _libssh2_wait_socket() we can see that the select
blocks infinitely, but there is a
code which should handle the timeout.

Code:
    /* Note that this COULD be made to use a timeout that perhaps could
be
       customizable by the app or something... */
    rc = select(session->socket_fd + 1, readfd, writefd, NULL, NULL);

    if(rc <= 0) {
        /* timeout (or error), bail out with a timeout error */
        session->err_code = LIBSSH2_ERROR_TIMEOUT;
        return LIBSSH2_ERROR_TIMEOUT;
    }

Is there any reason not to add a timeout parameter as follows?:
    rc = select(session->socket_fd + 1, readfd, writefd, NULL,
session->timeout);

This would only require to add 'timeout' into the session struct and to
create a function API which permits to set its value.
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-09