Skip to content

Commit 3ebee77

Browse files
samantharitterkevinAlbs
authored andcommitted
CDRIVER-3823 ignore SIGPIPE on osx (#716)
1 parent c2b897c commit 3ebee77

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/libmongoc/src/mongoc/mongoc-socket.c

+9
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,9 @@ mongoc_socket_new (int domain, /* IN */
993993
#else
994994
int sd;
995995
#endif
996+
#ifdef SO_NOSIGPIPE
997+
int on = 1;
998+
#endif
996999

9971000
ENTRY;
9981001

@@ -1017,6 +1020,12 @@ mongoc_socket_new (int domain, /* IN */
10171020
_mongoc_socket_setkeepalive (sd);
10181021
}
10191022

1023+
/* Set SO_NOSIGPIPE, to ignore SIGPIPE on writes for platforms where
1024+
setting MSG_NOSIGNAL on writes is not supported (primarily OSX). */
1025+
#ifdef SO_NOSIGPIPE
1026+
setsockopt(sd, SOL_SOCKET, SO_NOSIGPIPE, &on, sizeof(on));
1027+
#endif
1028+
10201029
sock = (mongoc_socket_t *) bson_malloc0 (sizeof *sock);
10211030
sock->sd = sd;
10221031
sock->domain = domain;

0 commit comments

Comments
 (0)