cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: problem in ftp/ssl "LIST " operation

From: Kumar Swamy. Bhatt <kswamy_at_inmage.net>
Date: Mon, 15 Jan 2007 21:33:55 -0800

Greetings,

I am using latest version of libcurl( 7.16.0) in windows. I am new to curl and am trying to make it work.

 I am getting a curl connection handle initially and reusing the same handle for various operations like uploading files , deleting and renaming files. After each of these operations I use curl_easy_reset to reset the curl handle.

But During LIST operation I am observing that curl gets into an infinite loop. LIST operation goes fine if there are any relevant files matching the input file specification. Problem arises when there is no file matching the input file and server returns nothing. Here curl complains that connection is died and retry with a fresh connect.

 

Execution enters into this loop.

if((data->reqdata.keep.bytecount+k->headerbytecount == 0) &&

     conn->bits.reuse &&

     !conn->bits.no_body) {

    /* We got no data, we attempted to re-use a connection and yet we want a

       "body". This might happen if the connection was left alive when we were

       done using it before, but that was closed when we wanted to read from

       it again. Bad luck. Retry the same request on a fresh connect! */

    infof(conn->data, "Connection died, retrying a fresh connect\n");

    *url = strdup(conn->data->change.url);

I observed that connection is established properly and command “LIST” is issued. But in the following piece of code

  res = Curl_do(&conn, &do_done);

      if(res == CURLE_OK) {

        res = Transfer(conn); /* now fetch that URL please */

        if(res == CURLE_OK) {

          retry = Curl_retry_request(conn, &newurl);

When function transfer (conn) tries to get the Server response, and server returns no bytes when the relevant file list is empty, data->reqdata.keep.bytecount+k->headerbytecount remains zero. Curl_retry_request assumes that connection’s died and retries it again

The OS is Windows Server 2003. FTP server: ProFTPD Version 1.2.10.

Am I using curl in a wrong way?? Any help would be GREATLY appreciated.

Thanks,
Kumar

=========================================================================
Here's my source code
/***************************************************************************
       curl_easy_reset(pCurl);

      (void)tal::SetTimeouts(pCurl,pData->m_lConnectTimeout,pData->m_lResponseTimeout);

      (void)tal::SetTransportParameters(pCurl,userpassword,(char *)pUser.c_str(),

                                                            (char *)pPassword.c_str(), pPort);

      (void)tal::SetURL(pCurl,pTo,szUrl);

      if(msg.GetCommHeader().GetSecureMode())

      {

            SetSecurityParameters(pData,pCurl);

      }

      CURLcode res;

 

      char bufCustomCommand[MAX_FILE_PATH_LENGTH+6];

      MemoryStruct chunk = {0};

      int retries = 0;

      memset(bufCustomCommand,0,MAX_FILE_PATH_LENGTH+6);

      strcpy(bufCustomCommand,"LIST ");

      strncat(bufCustomCommand,pFileSpec,MAX_FILE_PATH_LENGTH);

      bufCustomCommand[5+strlen(pFileSpec)] = '\0';

      curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, bufCustomCommand);

      curl_easy_setopt(curl, CURLOPT_VERBOSE, true);

      curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);

      curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&chunk);

               

=========================================================================
* Issue another request to this URL: 'ftp://10.0.1.28/'

* Examining connection #0 for reuse

* Re-using existing connection! (#0) with host 10.0.1.28

* Connected to 10.0.1.28 (10.0.1.28) port 21 (#0)

> CWD /home/svsystems

< 250 CWD command successful

> PASV

* Connect data stream passively

< 227 Entering Passive Mode (10,0,1,28,185,17).

* Trying 10.0.1.28... * connected

* Connecting to 10.0.1.28 (10.0.1.28) port 47377

> LIST /home/svsystems/05D60AC7-2A9D-A842-B01D8EFF6C533D65/F/resync/completed_sd

ni_*

< 150 Opening ASCII mode data connection for file list

* Doing the SSL/TLS handshake on the data stream

* SSL connection using DHE-RSA-AES256-SHA

* Server certificate:

* subject: /C=US/ST=CA/L=Santa Clara/O=Inmage/OU=Inmage/CN=Inmage/emailAd

dress=Inmage_at_inmage.com

* start date: 2005-07-01 20:19:53 GMT

* expire date: 2006-07-01 20:19:53 GMT

* issuer: /C=US/ST=CA/L=Santa Clara/O=Inmage/OU=Inmage/CN=Inmage/emailAdd

ress=Inmage_at_inmage.com

* SSL certificate verify result: unable to get local issuer certificate (20), co

ntinuing anyway.

* Maxdownload = -1

* Connection died, retrying a fresh connect

< 226 Transfer complete.

* Issue another request to this URL: 'ftp://10.0.1.28/'

* Examining connection #0 for reuse

* Re-using existing connection! (#0) with host 10.0.1.28

* Connected to 10.0.1.28 (10.0.1.28) port 21 (#0)

> CWD /home/svsystems

< 250 CWD command successful

> PASV

* Connect data stream passively

< 227 Entering Passive Mode (10,0,1,28,185,19).

* Trying 10.0.1.28... * connected

* Connecting to 10.0.1.28 (10.0.1.28) port 47379

> LIST /home/svsystems/05D60AC7-2A9D-A842-B01D8EFF6C533D65/F/resync/completed_sd

ni_*

< 150 Opening ASCII mode data connection for file list

* Doing the SSL/TLS handshake on the data stream

* SSL connection using DHE-RSA-AES256-SHA

* Server certificate:

* subject: /C=US/ST=CA/L=Santa Clara/O=Inmage/OU=Inmage/CN=Inmage/emailAd

dress=Inmage_at_inmage.com

* start date: 2005-07-01 20:19:53 GMT

* expire date: 2006-07-01 20:19:53 GMT

* issuer: /C=US/ST=CA/L=Santa Clara/O=Inmage/OU=Inmage/CN=Inmage/emailAdd

ress=Inmage_at_inmage.com

* SSL certificate verify result: unable to get local issuer certificate (20), co

ntinuing anyway.

* Maxdownload = -1

* Connection died, retrying a fresh connect

< 226 Transfer complete.

* Issue another request to this URL: 'ftp://10.0.1.28/'

* Examining connection #0 for reuse

* Re-using existing connection! (#0) with host 10.0.1.28

* Connected to 10.0.1.28 (10.0.1.28) port 21 (#0)

> CWD /home/svsystems

< 250 CWD command successful

> PASV

* Connect data stream passively

< 227 Entering Passive Mode (10,0,1,28,185,21).

* Trying 10.0.1.28... * connected

* Connecting to 10.0.1.28 (10.0.1.28) port 47381

> LIST /home/svsystems/05D60AC7-2A9D-A842-B01D8EFF6C533D65/F/resync/completed_sd

ni_*

< 150 Opening ASCII mode data connection for file list

* Doing the SSL/TLS handshake on the data stream

* SSL connection using DHE-RSA-AES256-SHA

* Server certificate:

* subject: /C=US/ST=CA/L=Santa Clara/O=Inmage/OU=Inmage/CN=Inmage/emailAd

dress=Inmage_at_inmage.com

* start date: 2005-07-01 20:19:53 GMT

* expire date: 2006-07-01 20:19:53 GMT

* issuer: /C=US/ST=CA/L=Santa Clara/O=Inmage/OU=Inmage/CN=Inmage/emailAdd

ress=Inmage_at_inmage.com

* SSL certificate verify result: unable to get local issuer certificate (20), co

ntinuing anyway.

* Maxdownload = -1

* Connection died, retrying a fresh connect

< 226 Transfer complete.

* Issue another request to this URL: 'ftp://10.0.1.28/'

* Examining connection #0 for reuse

* Re-using existing connection! (#0) with host 10.0.1.28

* Connected to 10.0.1.28 (10.0.1.28) port 21 (#0)

> CWD /home/svsystems

< 250 CWD command successful

> PASV

* Connect data stream passively

< 227 Entering Passive Mode (10,0,1,28,185,23).

* Trying 10.0.1.28... * connected

* Connecting to 10.0.1.28 (10.0.1.28) port 47383

> LIST /home/svsystems/05D60AC7-2A9D-A842-B01D8EFF6C533D65/F/resync/completed_sdni_*

< 150 Opening ASCII mode data connection for file list

* Doing the SSL/TLS handshake on the data stream

* SSL connection using DHE-RSA-AES256-SHA

* Server certificate:

* subject: /C=US/ST=CA/L=Santa Clara/O=Inmage/OU=Inmage/CN=Inmage/emailAd

dress=Inmage_at_inmage.com

* start date: 2005-07-01 20:19:53 GMT

* expire date: 2006-07-01 20:19:53 GMT

* issuer: /C=US/ST=CA/L=Santa Clara/O=Inmage/OU=Inmage/CN=Inmage/emailAdd

ress=Inmage_at_inmage.com

* SSL certificate verify result: unable to get local issuer certificate (20), co

ntinuing anyway.

* Maxdownload = -1

* Connection died, retrying a fresh connect

< 226 Transfer complete.

* Issue another request to this URL: 'ftp://10.0.1.28/'

* Examining connection #0 for reuse

* Re-using existing connection! (#0) with host 10.0.1.28

* Connected to 10.0.1.28 (10.0.1.28) port 21 (#0)

> CWD /home/svsystems

< 250 CWD command successful

> PASV

* Connect data stream passively

< 227 Entering Passive Mode (10,0,1,28,185,25).

* Trying 10.0.1.28... * connected

* Connecting to 10.0.1.28 (10.0.1.28) port 47385

> LIST /home/svsystems/05D60AC7-2A9D-A842-B01D8EFF6C533D65/F/resync/completed_sdni_*

< 150 Opening ASCII mode data connection for file list

* Doing the SSL/TLS handshake on the data stream

* SSL connection using DHE-RSA-AES256-SHA

* Server certificate:

* subject: /C=US/ST=CA/L=Santa Clara/O=Inmage/OU=Inmage/CN=Inmage/emailAd

dress=Inmage_at_inmage.com

* start date: 2005-07-01 20:19:53 GMT

* expire date: 2006-07-01 20:19:53 GMT

* issuer: /C=US/ST=CA/L=Santa Clara/O=Inmage/OU=Inmage/CN=Inmage/emailAdd

ress=Inmage_at_inmage.com

* SSL certificate verify result: unable to get local issuer certificate (20), co

ntinuing anyway.

* Maxdownload = -1

* Connection died, retrying a fresh connect

< 226 Transfer complete.

* Issue another request to this URL: 'ftp://10.0.1.28/'

* Examining connection #0 for reuse

* Re-using existing connection! (#0) with host 10.0.1.28

* Connected to 10.0.1.28 (10.0.1.28) port 21 (#0)

> CWD /home/svsystems

< 250 CWD command successful

> PASV

* Connect data stream passively

< 227 Entering Passive Mode (10,0,1,28,185,27).

* Trying 10.0.1.28... * connected

* Connecting to 10.0.1.28 (10.0.1.28) port 47387

> LIST /home/svsystems/05D60AC7-2A9D-A842-B01D8EFF6C533D65/F/resync/completed_sdni_*

< 150 Opening ASCII mode data connection for file list

* Doing the SSL/TLS handshake on the data stream

* SSL connection using DHE-RSA-AES256-SHA

* Server certificate:

* subject: /C=US/ST=CA/L=Santa Clara/O=Inmage/OU=Inmage/CN=Inmage/emailAd

dress=Inmage_at_inmage.com

* start date: 2005-07-01 20:19:53 GMT

* expire date: 2006-07-01 20:19:53 GMT

* issuer: /C=US/ST=CA/L=Santa Clara/O=Inmage/OU=Inmage/CN=Inmage/emailAdd

ress=Inmage_at_inmage.com

* SSL certificate verify result: unable to get local issuer certificate (20), co

ntinuing anyway.

* Maxdownload = -1

* Connection died, retrying a fresh connect

< 226 Transfer complete.

* Issue another request to this URL: 'ftp://10.0.1.28/'

* Examining connection #0 for reuse

* Re-using existing connection! (#0) with host 10.0.1.28

* Connected to 10.0.1.28 (10.0.1.28) port 21 (#0)

> CWD /home/svsystems

< 250 CWD command successful

> PASV

* Connect data stream passively

< 227 Entering Passive Mode (10,0,1,28,185,29).

* Trying 10.0.1.28... * connected

* Connecting to 10.0.1.28 (10.0.1.28) port 47389

> LIST /home/svsystems/05D60AC7-2A9D-A842-B01D8EFF6C533D65/F/resync/completed_sd

ni_*

< 150 Opening ASCII mode data connection for file list

* Doing the SSL/TLS handshake on the data stream

* SSL connection using DHE-RSA-AES256-SHA

* Server certificate:

* subject: /C=US/ST=CA/L=Santa Clara/O=Inmage/OU=Inmage/CN=Inmage/emailAd

dress=Inmage_at_inmage.com

* start date: 2005-07-01 20:19:53 GMT

* expire date: 2006-07-01 20:19:53 GMT

* issuer: /C=US/ST=CA/L=Santa Clara/O=Inmage/OU=Inmage/CN=Inmage/emailAdd

ress=Inmage_at_inmage.com

* SSL certificate verify result: unable to get local issuer certificate (20), co

ntinuing anyway.

* Maxdownload = -1

* Connection died, retrying a fresh connect

< 226 Transfer complete.

* Issue another request to this URL: 'ftp://10.0.1.28/'

* Examining connection #0 for reuse

* Re-using existing connection! (#0) with host 10.0.1.28

* Connected to 10.0.1.28 (10.0.1.28) port 21 (#0)

> CWD /home/svsystems

< 250 CWD command successful

> PASV

* Connect data stream passively

< 227 Entering Passive Mode (10,0,1,28,185,31).

* Trying 10.0.1.28... * connected

* Connecting to 10.0.1.28 (10.0.1.28) port 47391

> LIST /home/svsystems/05D60AC7-2A9D-A842-B01D8EFF6C533D65/F/resync/completed_sd

ni_*

< 150 Opening ASCII mode data connection for file list

* Doing the SSL/TLS handshake on the data stream

* SSL connection using DHE-RSA-AES256-SHA

* Server certificate:

* subject: /C=US/ST=CA/L=Santa Clara/O=Inmage/OU=Inmage/CN=Inmage/emailAd

dress=Inmage_at_inmage.com

* start date: 2005-07-01 20:19:53 GMT

* expire date: 2006-07-01 20:19:53 GMT

* issuer: /C=US/ST=CA/L=Santa Clara/O=Inmage/OU=Inmage/CN=Inmage/emailAdd

ress=Inmage_at_inmage.com

* SSL certificate verify result: unable to get local issuer certificate (20), co

ntinuing anyway.

* Maxdownload = -1

* Connection died, retrying a fresh connect

< 226 Transfer complete.

* Issue another request to this URL: 'ftp://10.0.1.28/'

* Examining connection #0 for reuse

* Re-using existing connection! (#0) with host 10.0.1.28

* Connected to 10.0.1.28 (10.0.1.28) port 21 (#0)

> CWD /home/svsystems

< 250 CWD command successful

> PASV

* Connect data stream passively

< 227 Entering Passive Mode (10,0,1,28,185,33).

* Trying 10.0.1.28... * connected

* Connecting to 10.0.1.28 (10.0.1.28) port 47393

> LIST /home/svsystems/05D60AC7-2A9D-A842-B01D8EFF6C533D65/F/resync/completed_sd

ni_*

< 150 Opening ASCII mode data connection for file list

* Doing the SSL/TLS handshake on the data stream

* SSL connection using DHE-RSA-AES256-SHA

* Server certificate:

* subject: /C=US/ST=CA/L=Santa Clara/O=Inmage/OU=Inmage/CN=Inmage/emailAd

dress=Inmage_at_inmage.com

* start date: 2005-07-01 20:19:53 GMT

* expire date: 2006-07-01 20:19:53 GMT

* issuer: /C=US/ST=CA/L=Santa Clara/O=Inmage/OU=Inmage/CN=Inmage/emailAdd

ress=Inmage_at_inmage.com

* SSL certificate verify result: unable to get local issuer certificate (20), co

ntinuing anyway.

* Maxdownload = -1

* Connection died, retrying a fresh connect

< 226 Transfer complete.

* Issue another request to this URL: 'ftp://10.0.1.28/'

* Examining connection #0 for reuse

* Re-using existing connection! (#0) with host 10.0.1.28

* Connected to 10.0.1.28 (10.0.1.28) port 21 (#0)

> CWD /home/svsystems

< 250 CWD command successful

> PASV

* Connect data stream passively

< 227 Entering Passive Mode (10,0,1,28,185,35).

* Trying 10.0.1.28... * connected

* Connecting to 10.0.1.28 (10.0.1.28) port 47395

> LIST /home/svsystems/05D60AC7-2A9D-A842-B01D8EFF6C533D65/F/resync/completed_sd

ni_*

< 150 Opening ASCII mode data connection for file list

* Doing the SSL/TLS handshake on the data stream

* SSL connection using DHE-RSA-AES256-SHA

* Server certificate:

* subject: /C=US/ST=CA/L=Santa Clara/O=Inmage/OU=Inmage/CN=Inmage/emailAd

dress=Inmage_at_inmage.com

* start date: 2005-07-01 20:19:53 GMT

* expire date: 2006-07-01 20:19:53 GMT

* issuer: /C=US/ST=CA/L=Santa Clara/O=Inmage/OU=Inmage/CN=Inmage/emailAdd

ress=Inmage_at_inmage.com

* SSL certificate verify result: unable to get local issuer certificate (20), co

ntinuing anyway.

* Maxdownload = -1

* Connection died, retrying a fresh connect

< 226 Transfer complete.

* Issue another request to this URL: 'ftp://10.0.1.28/'

* Examining connection #0 for reuse

* Re-using existing connection! (#0) with host 10.0.1.28

* Connected to 10.0.1.28 (10.0.1.28) port 21 (#0)

> CWD /home/svsystems

< 250 CWD command successful

> PASV

* Connect data stream passively

< 227 Entering Passive Mode (10,0,1,28,185,37).

* Trying 10.0.1.28... * connected

* Connecting to 10.0.1.28 (10.0.1.28) port 47397

> LIST /home/svsystems/05D60AC7-2A9D-A842-B01D8EFF6C533D65/F/resync/completed_sd

ni_*


--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.16.9/623 - Release Date: 1/11/2007 3:33 PM



--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.16.9/623 - Release Date: 1/11/2007 3:33 PM
 
Received on 2007-01-16