cURL / Mailing Lists / curl-library / Single Mail


Re: Proper way to convert ssh.c to non-blocking

From: James Housley <>
Date: Sun, 10 Jun 2007 18:06:34 -0400

On Jun 10, 2007, at 5:03 PM, Daniel Stenberg wrote:

> On Sun, 10 Jun 2007, James Housley wrote:
>> I know from pervious discussions that once libssh2 works in non-
>> blocking mode that ssh.c will need to be converted to run in a
>> state machine to "play nice" with the rest of libcurl. I also
>> remember being told that ftp.c is not the ideal way it should be
>> done, but I don't remember what was the best example of how it
>> should be done.
> Actually, ftp.c is a pretty good example (the _really_ bad examples
> are tftp.c, file.c, telnet.c and ldap.c). The bad places in ftp.c
> are hopefully all marked "BLOCKING". It does feature a pretty
> complicated state machine that was implemented and goes a long way
> in attempting to work nicely non-blocking.
>> If I am right for the actual transfers Curl_setup_transfer() would
>> be called and then the state machine would run from withing the
>> read and write call backs.
> Well, the (protocol-specific) read and write functions I would call
> them! :-) (not callbacks)
>> Would the same be done for connect?
> For the connect phase, you can view the ftp.c example for how it
> does it. The same function will simply be called repeatedly until
> it sets *done = TRUE.
>> Below is a highly edited version of the connect only showing the
>> routines that can block. Do I just do an initial transfer setup
>> with unknown size for connect?
> No, the connect phase is only connecting (and authenticating) to
> the host, it does no transfer. The transfer is inited by the DO-
> command. The procedure is like:
> 1 connect
> 2 do
> 3 done
> [possibly loop to 2 when another request is done on a persistant
> connection]
> 4 disconnect
> Most protocols do nothing special on disconnect (except FTP again).

Thanks for all the above. So as long as Curl_ssh_connect returns
CURLE_OK and sets *done = FALSE all is good? Okay.


/"\   ASCII Ribbon Campaign  .
\ / - NO HTML/RTF in e-mail  .
  X  - NO Word docs in e-mail .
/ \ -----------------------------------------------------------------     The Power to Serve
In theory there is no difference between theory and practice.
In practice there is no similarity.
       -- From the "I wish I'd said that" archives.
Received on 2007-06-11