cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Nonblocking libssh2 change

From: James Housley <jim_at_thehousleys.net>
Date: Fri, 8 Jun 2007 20:54:36 -0400

On Jun 8, 2007, at 3:44 PM, Dan Fandrich wrote:

> I saw the changes going in to libcurl to support the new fully
> nonblocking
> libssh2 implementation just added to CVS. I'm wondering if all those
> new #if statements are really necessary. In most cases, they're just
> turning calls like:
>
> i = libssh2_userauth_publickey_fromfile(...);
>
> into busy loops like:
>
> while ((i = libssh2_userauth_publickey_fromfile(...)) ==
> LIBSSH2_ERROR_EAGAIN)
> ;

But is some places it is more complex

   do {
     authlist = libssh2_userauth_list(...));

     if (!authlist && (libssh2_session_last_errno(ssh->ssh_session) !=
                       LIBSSH2_ERROR_EAGAIN)) {
        < do the error >
     }
   } while (!authlist);

>
> I have two questions:
>
> 1) Since LIBSSH2_ERROR_EAGAIN shouldn't be a valid return code in
> the older,
> blocking libssh2, why not get rid of the non-looping constructs in
> libcurl
> altogether? The loops will only ever be executed once in older
> libssh2.
>
> 2) Why bother with setting libssh2 into nonblocking mode at all if
> we need
> all these loops in libcurl to get around it? Yes, ideally libcurl
> would be
> changed to properly handle nonblocking mode itself, but when that
> happens
> this can be addressed. If we just want nonblocking mode during the
> data
> transfer, why not just switch libssh2 into nonblocking mode during
> that
> phase?
>
> There are so many #if statements now in the code, it makes it hard to
> read. It would be nice to avoid as many of them as possible. I
> wouldn't
> even complain about eliminating compatibility with older libssh2
> versions
> altogether, since there are some serious bugs with those versions,
> anyway.
>
>>>> Dan
> --
> http://www.MoveAnnouncer.com The web change of address
> service
> Let webmasters know that your web site has moved

I know the code is ugly with all the #if, but there are no execution
side affects. I would have no problem dropping libssh2 support for
versions older the 0.15, once it is release.

My goal is to start safely migrating more and more of the code to use
the non-blocking properly.

Jim

--
/"\   ASCII Ribbon Campaign  .
\ / - NO HTML/RTF in e-mail  .
  X  - NO Word docs in e-mail .
/ \ -----------------------------------------------------------------
jeh@FreeBSD.org      http://www.FreeBSD.org     The Power to Serve
jim@TheHousleys.Net  http://www.TheHousleys.net
---------------------------------------------------------------------
Do not meddle in the affairs of dragons, for you are crunchy and taste
     good with ketchup.
Received on 2007-06-09