Re: Converting ssh.c (sftp) to use Curl_setup_transfer()
Date: Tue, 26 Jun 2007 22:09:03 +0200 (CEST)
On Tue, 26 Jun 2007, James Housley wrote:
> I am about to the point, for download lets say, to use Curl_setup_transfer().
> Looking at the attached lib/ssh.c at line 1490. I obviously need to remove
> the #if 0/#endif, and add a state(conn, SSH_STOP); break;
... and not do the sftp read loop that comes after it I take it! ;-)
> But the problem I am having is it isn't working, and I am not sure it will.
> The SSH protocols require both transmitting and receiving to receive data
> (and transmit too). So the socket that gets passed in for a download will
> only be checked for data to read, but part of the time it will need to be
> checked that it is okay to transmit.
Well, Curl_setup_transfer() can be told to use the same socket descriptor for
both recv and send, and you should probably set both even for downloads-only
since you do need to check it for writability (at times).
> Is the most correct way to implement these protocols is to not use
> Curl_setup_transfer() and just do the reads in the state machine. Using the
> state machine will return in multi mode when blocking would occur.
If I would do it, I think I would call Curl_setup_transfer() to set both
reading and writing, and then make sure the sftp read/write functions deal
with both reading and writing accordingly. That may of course use the same or
another state machine function.
BTW, a totally separate note: please try to kill trailing whitespace in the
files you're editing. This ssh.c one is full of them...
-- Commercial curl and libcurl Technical Support: http://haxx.se/curl.htmlReceived on 2007-06-26