cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: FTP and CURLMOPT_PIPELINING

From: Dmitri Shubin <sbn_at_tbricks.com>
Date: Mon, 13 Dec 2010 13:33:22 +0300

Daniel Stenberg wrote:
> On Mon, 13 Dec 2010, Dmitri Shubin wrote:
>
>> Is CURLMOPT_PIPELINING supposed to work with FTP transfers?
>
> No. I actually think the docs is pretty clear on this:
Yes, but to my surprise I found that enabling it leads to using single
connection for multiple FTP transfers from the same server.

>
>> When I start 2 FTP downloads from the same server using multi
>> interface with this option enabled only one download succeeded.
>
> That's a bug then!
>
> Can you provide source code for a small application that experiences
> this failure to help us debug this?
>
I use modified version of 'multi-double.c' example
(docs/examples/multi-double.c in libcurl 7.21.2 distribution).
Here is a patch to it:

11a12,13
> #include <assert.h>
>
21a24,47
> FILE *log_file = NULL;
>
> static int debug_func(CURL *curl_handle, curl_infotype info, char
*ptr, size_t size, void *userdata)
> {
> char c = ptr[size];
> ptr[size] = '\0';
> switch (info) {
> case CURLINFO_HEADER_IN:
> fprintf(log_file, "%p\t< %s", curl_handle, ptr);
> break;
> case CURLINFO_HEADER_OUT:
> fprintf(log_file, "%p\t> %s", curl_handle, ptr);
> break;
> }
> ptr[size] = c;
> fflush(log_file);
> return 0;
> }
>
> static size_t write_func(void *ptr, size_t size, size_t nmemb, void
*userdata)
> {
> return size*nmemb;
> }
>
32a59,60
> log_file = fopen("curl.log", "w");
>
37c65,68
< curl_easy_setopt(http_handle, CURLOPT_URL, "http://www.example.com/");

---
 >   curl_easy_setopt(http_handle, CURLOPT_URL, 
"ftp://ftp.kernel.org/bin/compress");
 >   assert(curl_easy_setopt(http_handle, CURLOPT_DEBUGFUNCTION, 
debug_func) == CURLE_OK);
 >   assert(curl_easy_setopt(http_handle, CURLOPT_VERBOSE, (long)1) == 
CURLE_OK);
 >   assert(curl_easy_setopt(http_handle, CURLOPT_WRITEFUNCTION, 
write_func) == CURLE_OK);
40c71,74
<   curl_easy_setopt(http_handle2, CURLOPT_URL, "http://localhost/");
---
 >   curl_easy_setopt(http_handle2, CURLOPT_URL, 
"ftp://ftp.kernel.org/bin/ls");
 >   assert(curl_easy_setopt(http_handle2, CURLOPT_DEBUGFUNCTION, 
debug_func) == CURLE_OK);
 >   assert(curl_easy_setopt(http_handle2, CURLOPT_VERBOSE, (long)1) == 
CURLE_OK);
 >   assert(curl_easy_setopt(http_handle2, CURLOPT_WRITEFUNCTION, 
write_func) == CURLE_OK);
43a78
 >   curl_multi_setopt(multi_handle, CURLMOPT_PIPELINING, (long)1);
Thanks!
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2010-12-13