1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-22 08:08:50 -05:00

SO_NOSIGPIPE

This commit is contained in:
Daniel Stenberg 2004-10-11 17:23:41 +00:00
parent 5322a86313
commit 34342bcd19
2 changed files with 26 additions and 0 deletions

View File

@ -6,6 +6,12 @@
Changelog Changelog
Daniel (11 October 2004)
- libcurl now uses SO_NOSIGPIPE for systems that support it (Mac OS X 10.2 or
later is one) to inhibit the SIGPIPE signal when writing to a socket while
the peer dies. The same effect is provide by the MSG_NOSIGNAL parameter to
send() on other systems. Alan Pinstein verified the fix.
Gisle (6 October 2004) Gisle (6 October 2004)
- For USE_LIBIDN builds: Added Top-Level-Domain (TLD) check of host-name - For USE_LIBIDN builds: Added Top-Level-Domain (TLD) check of host-name
used in fix_hostname(). Checks if characters in 'host->name' (indirectly used in fix_hostname(). Checks if characters in 'host->name' (indirectly

View File

@ -558,6 +558,23 @@ static void tcpnodelay(struct connectdata *conn,
#endif #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 /* singleipconnect() connects to the given IP only, and it may return without
having connected if used from the multi interface. */ having connected if used from the multi interface. */
static curl_socket_t static curl_socket_t
@ -584,6 +601,9 @@ singleipconnect(struct connectdata *conn,
if(data->set.tcp_nodelay) if(data->set.tcp_nodelay)
tcpnodelay(conn, sockfd); tcpnodelay(conn, sockfd);
#ifdef SO_NOSIGPIPE
nosigpipe(conn, sockfd);
#endif
if(conn->data->set.device) { if(conn->data->set.device) {
/* user selected to bind the outgoing socket to a specified "device" /* user selected to bind the outgoing socket to a specified "device"
before doing connect */ before doing connect */