cURL / Mailing Lists / curl-library / Single Mail

curl-library

sigpipe when putting medium-sized file

From: Josh Anon <josha_at_pixar.com>
Date: Fri, 26 Dec 2003 15:32:40 -0800

Curl has been working really well for me--awesome job! However, when I
was testing something earlier, I tried getting a 245MB file from one
machine and putting it to another. Unfortunately, the put dies with a
sigpipe (reproducibly). I used curl to get the file, though, and that
worked fine.

The stack is: myFunc --> Curl_perform -> Transfer --> Curl_readwrite
--> Curl_write --> sendto

The code is:

int _fxtCurlPutFile(const char *src, const char *destURL) {
     CURL *curl;
     CURLcode res;
     FILE *inFile;

     curl = curl_easy_init();
     fprintf(stderr, "curling %s to %s\n", src, destURL);

     if (curl) {
        int hd;
        struct stat file_info;
        double transfer;
        
        hd = open(src, O_RDONLY);
        fstat(hd, &file_info);
        
        inFile = fdopen(hd, "rb");
        if (!inFile) {
            fprintf(stderr, "Unable to open file %s\n", src);
            return FXT_Error;
        }
        curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE);
        curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, debugCallback);

        //from
        curl_easy_setopt(curl, CURLOPT_READDATA, inFile);
        //going to
        curl_easy_setopt(curl, CURLOPT_URL, destURL);
        //enable upload in CURL
        curl_easy_setopt(curl, CURLOPT_UPLOAD, TRUE);
        //use PUT
        curl_easy_setopt(curl, CURLOPT_PUT, TRUE);
        //size. need the (long) for OS X
        curl_easy_setopt(curl, CURLOPT_INFILESIZE, (long)file_info.st_size);
        
        res = curl_easy_perform(curl);
        curl_easy_getinfo(curl,CURLINFO_SIZE_UPLOAD, &transfer);
        fprintf(stderr, "CURL put transferred %f bytes\n", transfer);
        
        close(hd);
        
        curl_easy_cleanup(curl);
        if (res != CURLE_OK) {
            fprintf(stderr, "Failed to put %s to %s with CURL error %i\n",
src, destURL, res);
            return FXT_Error;
        }
     } else {
        fprintf(stderr, "Unable to init CURL\n");
        return FXT_Error;
     }

     return FXT_Success;
}

and the output is:

curling /tmp/exportClip_1717_14440_1.mov to
http://XXX.YYY.ZZZ.WWW/test.mov
DBG: About to connect() to XXX.YYY.ZZZ.WWW

DBG: Connected to XXX.YYY.ZZZ.WWW (XXX.YYY.ZZZ.WWW) port 80

DBG: PUT /test.mov HTTP/1.1
Host: XXX.YYY.ZZZ.WWW
Pragma: no-cache
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
Content-Length: 245768369

DBG:
DBG:
DBG:
DBG:
DBG:
DBG:
DBG: HTTP/1.1 400 Bad Request

DBG: Date: Fri, 26 Dec 2003 23:25:06 GMT

DBG: Server: Apache/2.0.46 (Win32) DAV/2

DBG: Content-Length: 313

DBG: Connection: close

DBG: Content-Type: text/html; charset=iso-8859-1

DBG: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not
understand.<br />
</p>
<hr />
<address>Apache/2.0.46 (Win32) DAV/2 Server at XXX.YYY.ZZZ.WWW Port
80</address>
</body></html>

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not
understand.<br />
</p>
<hr />
<address>Apache/2.0.46 (Win32) DAV/2 Server at XXX.YYY.ZZZ.WWW Port
80</address>
</body></html>
Program received signal: "SIGPIPE".
(gdb)

any ideas?

Thanks, and happy new year!
Josh

---
Josh Anon
Studio Tools, Pixar Animation Studios
josha_at_pixar.com
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
Received on 2003-12-27