cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-tracker mailing list Archives

[ curl-Bugs-1465999 ] Libcurl doesn't reuse connection after aborting transfer.

From: SourceForge.net <noreply_at_sourceforge.net>
Date: Thu, 06 Apr 2006 14:34:55 -0700

Bugs item #1465999, was opened at 2006-04-06 18:34
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=1465999&group_id=976

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: ftp
Group: bad behaviour
Status: Open
Resolution: None
Priority: 5
Submitted By: Robson Braga Araujo (braga)
Assigned to: Daniel Stenberg (bagder)
Summary: Libcurl doesn't reuse connection after aborting transfer.

Initial Comment:
Libcurl disconnects from the FTP server when I remove
the easy handle from a multi handle to stop the
transfer. This is not necessary as libcurl maintains
the connection if I pass a range of the form X-Y. The
following testcase shows this bad behaviour. I tested
it against latest CVS (7.15.3-20060406).

#include <stdio.h>
#include <curl/curl.h>
#include <curl/easy.h>

int main() {
  CURL *c;
  CURLM *m;
  CURLMcode res;
  int running=1;
  int i=0;

  curl_global_init(CURL_GLOBAL_ALL);
  c = curl_easy_init();
  curl_easy_setopt(c, CURLOPT_VERBOSE, 1);
  curl_easy_setopt(c, CURLOPT_URL, "ftp://ftp.sunet.se/");
  curl_easy_perform(c);
  curl_easy_setopt(c, CURLOPT_URL,
"ftp://ftp.sunet.se/ls-lR");
  m = curl_multi_init();

  res = curl_multi_add_handle(m, c);

  do {
     res = curl_multi_perform(m, &running);
  } while (res==CURLM_CALL_MULTI_PERFORM);
  while (running) {
    struct timeval timeout;
    int rc; /* select() return code */

    fd_set fdread;
    fd_set fdwrite;
    fd_set fdexcep;
    int maxfd;

    FD_ZERO(&fdread);
    FD_ZERO(&fdwrite);
    FD_ZERO(&fdexcep);

    /* set a suitable timeout to play around with */
    timeout.tv_sec = 1;
    timeout.tv_usec = 0;

    /* get file descriptors from the transfers */
    curl_multi_fdset(m, &fdread, &fdwrite, &fdexcep,
&maxfd);

    rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep,
&timeout);

    switch(rc) {
    case -1:
      /* select error */
      break;
    case 0:
      /* timeout, do something else */
      break;
    default:
      /* one or more of curl's file descriptors say
there's data to read
         or write */
      while(CURLM_CALL_MULTI_PERFORM ==
            curl_multi_perform(m, &running));
      break;
    }
    if (i++ > 10) break;
  }

  curl_multi_remove_handle(m, c);
  curl_easy_setopt(c, CURLOPT_URL, "ftp://ftp.sunet.se");
  res = curl_multi_add_handle(m, c);

  while (running) {
    res = curl_multi_perform(m, &running);
    if (running <= 0) {
      fprintf(stderr, "nothing left running.\n");
      break;
    }
  }
  curl_multi_remove_handle(m, c);
  curl_easy_cleanup(c);
  curl_multi_cleanup(m);

  return res;
}

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=1465999&group_id=976
Received on 2006-04-06

These mail archives are generated by hypermail.

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

File upload with ASP.NET