cURL / Mailing Lists / curl-users / Single Mail

curl-users

[ curl-Bugs-588464 ] Pb with chained interrupted downloads

From: <noreply_at_sourceforge.net>
Date: Tue, 30 Jul 2002 02:46:26 -0700

Bugs item #588464, was opened at 2002-07-30 02:46
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=588464&group_id=976

Category: libcurl
Group: bad behaviour
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Daniel Stenberg (bagder)
Summary: Pb with chained interrupted downloads

Initial Comment:
Using the sample code given hereafter, which tries to
download one file by ftp, interrupting its download
twice before the end, and second or third
curl_easy_perform operation hangs and the callback is
never called.

The call stack while waiting is the following :
NTDLL! 77f827e8()
MSAFD! 74fd1815()
WS2_32! 75032006()
Curl_GetFTPResponse(char * 0x64874d41, connectdata *
0x00430670, int * 0x002f2708) line 232 + 45 bytes
ftp_cwd(connectdata * 0x002f2708, char * 0x00000000)
line 669 + 20 bytes
ftp_perform(connectdata * 0x648743a9) line 1406 + 10 bytes
Curl_ftp(connectdata * 0x6487f693) line 1899
Curl_do(connectdata * 0x002f2708) line 2164 + 3 bytes
Curl_perform(SessionHandle * 0x648725fa) line 927 + 10
bytes
curl_easy_perform(void * 0x00430048) line 230 + 10 bytes
main(int 1, char * * 0x00311530) line 61 + 9 bytes
mainCRTStartup() line 206 + 25 bytes
KERNEL32! 77e8d326()

But I had problems while debugging at this point :
sorry not to have more details... Hope this can be
reproduced on another computer.

#include "curl/curl.h"

#ifdef _DEBUG
# pragma comment(lib, "libcurld.lib")
#else
# pragma comment(lib, "libcurl.lib")
#endif

#define URL
"ftp://ftp.rge.com/pub/networking/curl/curl-7.9.8.zip"

struct ReadingData {
  long _lNbToRead;
  long _lNbRead;
};

size_t _ISReceiveFromCurl(void* ptr, size_t size,
size_t nmemb, void* data)
{
  ReadingData readingData = *(ReadingData*)data;
  int realsize = size * nmemb;
  printf("Read %i bytes from the file\n", realsize);
  readingData._lNbRead += realsize;
  if (readingData._lNbRead > readingData._lNbToRead) {
    printf("Ok : We have read %i > %i bytes\n",
readingData._lNbRead, readingData._lNbToRead);
    return -1;
  }
  return realsize;
}

int main(int argc, char* argv[])
{
  curl_global_init(CURL_GLOBAL_ALL);
  CURL* pCurlHandle = curl_easy_init();
  CURLcode err = curl_easy_setopt(pCurlHandle,
CURLOPT_URL, URL);
  err = curl_easy_setopt(pCurlHandle,
CURLOPT_READFUNCTION, NULL);
  err = curl_easy_setopt(pCurlHandle,
CURLOPT_WRITEFUNCTION, _ISReceiveFromCurl);
  curl_easy_setopt(pCurlHandle, CURLOPT_UPLOAD, false) ;
  ReadingData readingData;
  // First Read : 10000 bytes
  readingData._lNbToRead = 10000;
  readingData._lNbRead = 0;
  printf("First Read : %i bytes\n",
readingData._lNbToRead);
  err = curl_easy_setopt(pCurlHandle, CURLOPT_FILE,
(void *)&readingData);
  err = curl_easy_perform(pCurlHandle);
  printf("easy_perform result : %i\n", err);

  // Second Read : 10000 bytes
  readingData._lNbToRead = 10000;
  readingData._lNbRead = 0;
  printf("Second Read : %i bytes\n",
readingData._lNbToRead);
  err = curl_easy_perform(pCurlHandle);
  printf("easy_perform result : %i\n", err);

  // Third Read : all : 1000000000 bytes
  readingData._lNbToRead = 1000000000;
  readingData._lNbRead = 0;
  printf("Last Read : all bytes\n");
  err = curl_easy_perform(pCurlHandle);
  printf("easy_perform result : %i\n", err);

  return 0;
}

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

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=588464&group_id=976

-------------------------------------------------------
This sf.net email is sponsored by: Dice - The leading online job board
for high-tech professionals. Search and apply for tech jobs today!
http://seeker.dice.com/seeker.epl?rel_code=31
Received on 2002-07-30