mirror of
https://github.com/curl/curl.git
synced 2026-08-26 00:13:34 +03:00
socketpair: set SO_NOSIGPIPE where possible
Set SO_NOSIGPIPE on socketpair/inet-simulated socketpair implementations. eventfd and pipe() do not need/want it. Closes #20397
This commit is contained in:
parent
ef3101d181
commit
2a6ae3684e
3 changed files with 35 additions and 9 deletions
|
|
@ -294,6 +294,15 @@ static CURLcode sock_assign_addr(struct Curl_sockaddr_ex *dest,
|
|||
return CURLE_OK;
|
||||
}
|
||||
|
||||
#ifdef USE_SO_NOSIGPIPE
|
||||
int Curl_sock_nosigpipe(curl_socket_t sockfd)
|
||||
{
|
||||
int onoff = 1;
|
||||
return setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE,
|
||||
(void *)&onoff, sizeof(onoff));
|
||||
}
|
||||
#endif /* USE_SO_NOSIGPIPE */
|
||||
|
||||
static CURLcode socket_open(struct Curl_easy *data,
|
||||
struct Curl_sockaddr_ex *addr,
|
||||
curl_socket_t *sockfd)
|
||||
|
|
@ -333,15 +342,12 @@ static CURLcode socket_open(struct Curl_easy *data,
|
|||
}
|
||||
|
||||
#ifdef USE_SO_NOSIGPIPE
|
||||
{
|
||||
int onoff = 1;
|
||||
if(setsockopt(*sockfd, SOL_SOCKET, SO_NOSIGPIPE,
|
||||
(void *)&onoff, sizeof(onoff)) < 0) {
|
||||
failf(data, "setsockopt enable SO_NOSIGPIPE: %s",
|
||||
curlx_strerror(SOCKERRNO, errbuf, sizeof(errbuf)));
|
||||
*sockfd = CURL_SOCKET_BAD;
|
||||
return CURLE_COULDNT_CONNECT;
|
||||
}
|
||||
if(Curl_sock_nosigpipe(*sockfd) < 0) {
|
||||
failf(data, "setsockopt enable SO_NOSIGPIPE: %s",
|
||||
curlx_strerror(SOCKERRNO, errbuf, sizeof(errbuf)));
|
||||
sclose(*sockfd);
|
||||
*sockfd = CURL_SOCKET_BAD;
|
||||
return CURLE_COULDNT_CONNECT;
|
||||
}
|
||||
#endif /* USE_SO_NOSIGPIPE */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue