cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: SIGPIPE when uploading with CURLOPT_READDATA

From: Alan Pinstein <apinstein_at_mac.com>
Date: Mon, 11 Oct 2004 11:51:29 -0400

I have just finished testing the NEW patch and it works great! libcurl no longer SIGPIPEs on OS X in the situation I was facing (server stops listening to an HTTP request upload that exceeds the maxRequestLen [IIS 5.0 on Win2k]).

FWIW, it seems the "error" string reported by libcurl in this case is empty, at least as reported by CURLHandle via:

- (void)URLHandle:(NSURLHandle *)sender resourceDidFailLoadingWithReason:(NSString *)reason;

Thanks for figuring out this patch, it now allows our app to be graceful in a common situation.

Alan

 
On Monday, October 11, 2004, at 09:29AM, Daniel Stenberg <daniel-curl_at_haxx.se> wrote:

>On Mon, 11 Oct 2004, Jamie Lokier wrote:
>
>> Fwiw, I believe SO_NOSIGPIPE is also FreeBSD 5 option. It isn't mentioned in
>> the FreeBSD man pages, but it is in the header files.
>
>Then I wonder if this change is gonna work or just don't have any effect...
>
>> However, without testing, unless you've seen an example of this working in
>> another program, you might find it's not a TCP-layer option. I.e. you might
>> find it has to say SOL_SOCKET instead; I don't know.
>
>Ah, you're right. I was just stupidly copy'n'pasting some code from the
>TCP_NODELAY option...
>
>I've attached an updated patch that might actually work!
>
>--
> Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se
> Dedicated custom curl help for hire: http://haxx.se/curl.html
>Index: lib/connect.c
>===================================================================
>RCS file: /cvsroot/curl/curl/lib/connect.c,v
>retrieving revision 1.117
>diff -u -r1.117 connect.c
>--- lib/connect.c 6 Oct 2004 07:50:18 -0000 1.117
>+++ lib/connect.c 11 Oct 2004 13:26:23 -0000
>@@ -558,6 +558,23 @@
> #endif
> }
>
>+#ifdef SO_NOSIGPIPE
>+/* The preferred method on Mac OS X (10.2 and later) to prevent SIGPIPEs when
>+ sending data to a dead peer (instead of relying on the 4th argument to send
>+ being MSG_NOSIGNAL). Possibly also existing and in use on other BSD
>+ systems? */
>+static void nosigpipe(struct connectdata *conn,
>+ curl_socket_t sockfd)
>+{
>+ struct SessionHandle *data= conn->data;
>+ int onoff = 1;
>+ if(setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, (void *)&onoff,
>+ sizeof(onoff)) < 0)
>+ infof(data, "Could not set SO_NOSIGPIPE: %s\n",
>+ Curl_strerror(conn, Curl_ourerrno()));
>+}
>+#endif
>+
> /* singleipconnect() connects to the given IP only, and it may return without
> having connected if used from the multi interface. */
> static curl_socket_t
>@@ -584,6 +601,9 @@
> if(data->set.tcp_nodelay)
> tcpnodelay(conn, sockfd);
>
>+#ifdef SO_NOSIGPIPE
>+ nosigpipe(conn, sockfd);
>+#endif
> if(conn->data->set.device) {
> /* user selected to bind the outgoing socket to a specified "device"
> before doing connect */
>
>
Received on 2004-10-11