cURL / Mailing Lists / curl-library / Single Mail

curl-library

Nonblocking libssh2 change

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Fri, 8 Jun 2007 12:44:34 -0700

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)
  ;

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
Received on 2007-06-08