cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-library Mailing List Archives

Re: FW: scp upload failure memory leak

From: Jeff Weber <jweber_at_amsc.com>
Date: Wed, 28 May 2008 12:52:46 -0500

On Tue, May 27, 2008 at 11:51:14PM +0200, Daniel Stenberg wrote:
> On Tue, 27 May 2008, Jeff Weber wrote:
>
>> The new scp, sftp upload timeout test cases also pass without leaks
>> with the new scp-sftp-leaks-2.patch .
>
> Okay, so then at least it makes some things better and nothing got worse
> than before?
Indeed. Thanks for your patch. I need to upload files to a ssh
server. I need at least one of (scp, sftp) to work. Since now sftp
is working well, I'm good to go. Because of the issues I've been
having with scp, I've decided not to use it.
>
>> However, when I break the network connection during a series of scp
>> uploads that share the same connection, the CURLOPT_TIMEOUT doesn't
>> work, and I get memory leaks.
>
> That's weird. A lot of the transfer logic is the same, and the
> timeout logic should be identical between SCP and SFTP...
>
> So if CURLOPT_TIMEOUT doesn't work, how do you abort the transfer?
 I don't abort the transfer. curl_easy_perform() returns (after
 hanging for about 16min). with a return value of CURLE_OK, event
 though I set CURLOPT_TIMEOUT to 30sec.

 In summary, when I upload N files to a sftp URL with
 CURLOPT_TIMEOUT=30sec, then break the network connection,
 curl_easy_perform() runs for approx 30sec and returns with
 CURLE_OPERATION_TIMEDOUT (28), with no memory leaks. If I repeat the
 same test to the same ssh server using the scp protocol,
 curl_easy_perform() returns CURLE_OK after about 16min, and leaks
 memory. I got the
    Failed to free libssh2 scp subsystem
message.
[Note: since I originally posted, I've found that the scp timeout
response can vary, depending upon the interrupted state. More below.]

>
>> In all cases, I successfully set CURLOPT_TIMEOUT to 30sec before
>> starting the uploads and breaking the connection. However, when I
>> break the connection during the SSH_SCP_UPLOAD_INIT state, the
>> upload hangs for about 15min.
>
> Is it the libssh2_scp_send_ex() function call that hangs then?

I found 2 different scenarios where the the ssh state machine was
spinning:

If the state was SSH_SCP_WAIT_EOF, libssh2_channel_wait_eof() keeps
returning LIBSSH2_ERROR_EAGAIN. The state machine could never leave
the SSH_SCP_WAIT_EOF state.

If the state was SSH_SCP_UPLOAD_INIT, libssh2_scp_send_ex() keeps
returning LIBSSH2_ERROR_EAGAIN. The state machine could never leave
the SSH_SCP_UPLOAD_INIT state.

I didn't check all the scp state machine transitions.

    Jeff
“This e-mail message and any attachments are confidential and may be privileged.
If you are not the intended recipient please notify American Superconductor Corporation
immediately by replying to this message or by sending a message to postmaster_at_amsc.com
and destroy all copies of this message and any attachments.
Thank you.”
Received on 2008-05-28

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET