Skip to content

CDRIVER-3823 ignore SIGPIPE on osx #716

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/libmongoc/src/mongoc/mongoc-socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,9 @@ mongoc_socket_new (int domain, /* IN */
#else
int sd;
#endif
#ifdef SO_NOSIGPIPE
int on = 1;
#endif

ENTRY;

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

/* Set SO_NOSIGPIPE, to ignore SIGPIPE on writes for platforms where
setting MSG_NOSIGNAL on writes is not supported (primarily OSX). */
#ifdef SO_NOSIGPIPE
setsockopt(sd, SOL_SOCKET, SO_NOSIGPIPE, &on, sizeof(on));
#endif

sock = (mongoc_socket_t *) bson_malloc0 (sizeof *sock);
sock->sd = sd;
sock->domain = domain;
Expand Down