cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: non-blocking FTP

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 14 May 2008 00:34:08 +0200 (CEST)

On Tue, 13 May 2008, Jeff Weber wrote:

> I need to make nonblocking uploads of multiple files using either the scp://
> or ftp:// protocols. In some cases, the code must upload via scp://, in
> other cases ftp://.
>
> Given the comment in the libcurl-multi.3 -- man page, that ftp:// still
> contains some blocking code, even in the multi interface, I decided to use
> the easy interface, and split my transfer into pthreads.

Yeps, there are a few blocking cases still around.

> Most of the code is in the parent thread, and only the curl_easy_perform()
> in a child thread. If the child thread "takes too long", I cancel it.
> Regardless, the parent always calls curl_easy_cleanup(),
> curl_global_cleanup(). Unfortunately, cancelling curl_easy_perform() leads
> to memory leaks.

Yes. Doing that is badness! See this:

http://curl.haxx.se/docs/faq.html#How_do_I_stop_an_ongoing_transfe

> Are there any other suggestions for implementing nonblocking ftp://
> transfers?

You're on the right track. Just stop the transfers the right way and you'll be
fine.

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2008-05-14