cURL / Mailing Lists / curl-library / Single Mail

curl-library

NOSIGNAL option set but still receiving SIGPIPE

From: John Lee <jhn134910_at_gmail.com>
Date: Wed, 10 Mar 2010 16:07:49 +0000

Using 32-bit RHEL4, gcc 3.4.6, gdb 6.3.0.0-1.143, CURL version 7.12.1.
Using multi-interface via dedicated app thread. Multi-threaded app.
Sending in around 35 http requests a second. OK under smaller loads.

Leaving aside error handling I do the following with no error reported:
1) Set once
curl_global_init(CURL_GLOBAL_ALL);
multi_handle=curl_multi_init()
Create a number of easy_handles:
client_connection[i].easy_handle=curl_easy_init()
For each easy handle
Set easy handle state to IDLE (in my app)
Set easy options that apply to all handles: (NOSIGNAL, TIMEOUT, VERBOSE,
HEADER, HEADERFUNCTION, WRITEHEADER)

2) Each HTTP request attempt
Find an IDLE easy handle (in my app)
If one available set BUSY (in my app)
Set easy options that apply to particular easy handle: (URL, HTTPHEADERS,
WRITEFUNCTION, WRITEDATA)

3) Periodic calls to
resm=curl_multi_add_handle(multi_handle, client_connection[i].easy_handle)
while(CURLM_CALL_MULTI_PERFORM == curl_multi_perform(multi_handle,
&still_running)) ... (as per examples)
...
 while ((msg = curl_multi_info_read(multi_handle, &msgs_left)))
    {
        if(msg->msg == CURLMSG_DONE)
        {
            /* Find out which handle this message is about */
            for(idx=0; idx<configured_number_of_connections; idx++)
            {
                found =
                    ((msg->easy_handle ==
client_connection[idx].easy_handle)
                    && (client_connection_array[idx].state == BUSY));

                if(found)
                    break;
            }

            if((msg->data.result == CURLE_OK) && (found))
            {
                client_process_response pr =
                    client_connection[idx].config.response_callbk;

                if((*pr)(
client_connection_array[idx].config.destination_module,

client_connection_array[idx].config.destination_instance,

client_connection_array[idx].read_response.writeptr,

client_connection_array[idx].read_response.write_size))
                {
                    printf("HTTP client response callback returned an
error\n");
                }

                if((resm=curl_multi_remove_handle(multi_handle,
                    client_connection[idx].easy_handle)))
                {
                    printf("Failed to remove easy handle from multi-stack,
ret %d\n",
                        resm);
                }
                client_connection_array[idx].state = IDLE;
            }
...

Output:
....
<= Recv header, 26 bytes (0x1a)
0000: HTTP/1.1 400 Bad Request
<= Recv header, 37 bytes (0x25)
0000: Date: Wed, 10 Mar 2010 15:33:59 GMT
<= Recv header, 33 bytes (0x21)
0000: Server: Apache/2.0.52 (Red Hat)
<= Recv header, 21 bytes (0x15)
0000: Content-Length: 366
<= Recv header, 19 bytes (0x13)
0000: Connection: close
<= Recv header, 45 bytes (0x2d)
0000: Content-Type: text/html; charset=iso-8859-1
<= Recv data, 366 bytes (0x16e)
0000: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">.<html><head>.
0040: <title>400 Bad Request</title>.</head><body>.<h1>Bad Request</h1
0080: >.<p>Your browser sent a request that this server could not unde
00c0: rstand.<br />.The number of request header fields exceeds this s
0100: erver's limit.</p>.<hr>.<address>Apache/2.0.52 (Red Hat) Server
0140: at 127.0.0.1 Port 80</address>.</body></html>.

Program received signal SIGPIPE, Broken pipe.
[Switching to Thread -1208453440 (LWP 679)]
0x003fd7a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
(gdb) backtrace
#0 0x003fd7a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
#1 0x00676a58 in send () from /lib/tls/libpthread.so.0
#2 0x0098fb44 in Curl_write (conn=0x85c5fb8, sockfd=16, mem=0x8371c71,
len=67,
    written=0xbfe568bc) at sendf.c:292
#3 0x0099fdcd in Curl_readwrite (conn=0x85c5fb8, done=0xbfe56a12
"å\001\001") at transfer.c:1207
#4 0x009a4513 in curl_multi_perform (multi_handle=0x8342c98,
running_handles=0xbfe56bfc)
    at multi.c:485
#5 0x00a5d798 in http_client_send_request () at http_client.c:348
#6 0x0804ae16 in main_http_test_loop (arg=0x0) at main.c:360
#7 0x0804acf8 in main (argc=1, argv=0xbfe56e34) at main.c:310
(gdb)

Any idea what I'm doing wrong and why SIGPIPE is still getting handled?

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-03-10