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-1618521 ] Libcurl hangs without return when network interface is down

From: SourceForge.net <noreply_at_sourceforge.net>
Date: Tue, 19 Dec 2006 00:02:48 -0800

Bugs item #1618521, was opened at 2006-12-19 04:47
Message generated for change (Comment added) made by bagder
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=1618521&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: libcurl
Group: hang
Status: Open
>Resolution: Invalid
Priority: 5
Private: No
Submitted By: Xie Bo (happycoding)
Assigned to: Daniel Stenberg (bagder)
Summary: Libcurl hangs without return when network interface is down

Initial Comment:
Libcurl hangs without return when network interface is down while downloading. I waited at lease 30 minutes and it never returned.

$uname -a
Linux (none) 2.6.16.21-0.8-default #1 Mon Jul 3 18:25:39 UTC 2006 i686 i686 i386 GNU/Linux
$curl -V
curl 7.15.1 (i686-suse-linux) libcurl/7.15.1 OpenSSL/0.9.8a zlib/1.2.3 libidn/0.6.0 Protocols: tftp ftp gopher telnet dict ldap http file https ftps Features: IDN IPv6 Largefile NTLM SSL libz
$cat curltest.cpp
#include <curl/curl.h>
#include <string>
#include <cassert>
#include <iostream>

using namespace std;

size_t
writeData(void *ptr, size_t size, size_t nmemb, void *param)
{
    static int fileSize = 0;
    fileSize += size * nmemb;
    cout << "file size = " << fileSize << endl;
    return size * nmemb;
}

int main()
{
    string fileToDownload = "http://apache.justdn.org/ant/binaries/apache-ant-1.6.5-bin.zip";
    CURL *handle_ = curl_easy_init();
    assert( handle_ != NULL);

    curl_easy_setopt(handle_, CURLOPT_URL, fileToDownload.c_str());
    curl_easy_setopt(handle_, CURLOPT_VERBOSE, true);
    curl_easy_setopt(handle_, CURLOPT_WRITEFUNCTION, writeData);

    CURLcode ret = curl_easy_perform(handle_);
    assert(ret == CURLE_OK);

    return 0;
}
$g++ curltest.cpp -lcurl
$./a.out
* About to connect() to apache.justdn.org port 80
* Trying 216.92.2.131... * connected
* Connected to apache.justdn.org (216.92.2.131) prot 80
> GET /ant/binaries/apache-ant-1.6.5-bin.zip HTTP/1.1
Host: apache.justdn.org
Accept: */*

<HTTP/1.1 200 OK
<Date: Tue, 19 Dec 2006 03:29:21 GMT
<Server: Apache/1.3.29
<Last-Modified: Thu, 02 Jun 2005 13:49:55 GMT
<ETag: "537c55d-99aaf3-429f0e83"
<Accept-Ranges: bytes
<Content-Length: 10070771
<Content-Type: application/zip
file size = 1143
file size = 2523
...
file size = 310263 (At this time, I run 'ifdown eth0' in another shell to shutdown network interface, then libcurl will hang... )

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

>Comment By: Daniel Stenberg (bagder)
Date: 2006-12-19 09:02

Message:
Logged In: YES
user_id=1110
Originator: NO

If you don't use any time-out option and nothing "bad" happens on the
connection, then libcurl is *supposed* to hang since it waits for more data
to arrive. That's how TCP/IP is designed to work.

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

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

These mail archives are generated by hypermail.

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

File upload with ASP.NET