summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2013-03-13 18:38:18 +0000
committerjilles <jilles@FreeBSD.org>2013-03-13 18:38:18 +0000
commit32c02d0b8968e57fd82707d32b8e6d2cad297ff2 (patch)
tree6dfafd46344be81042e48d126bd556643de5733c /lib
parentfa21691aad5fcf1c62f5f242b1e0fa5b1a87d79c (diff)
downloadFreeBSD-src-32c02d0b8968e57fd82707d32b8e6d2cad297ff2.zip
FreeBSD-src-32c02d0b8968e57fd82707d32b8e6d2cad297ff2.tar.gz
libc: Avoid SIGPIPE when nscd closes the connection unexpectedly.
It is almost always a bug if nscd closes the connection unexpectedly but programs should not be killed with SIGPIPE for it. Reviewed by: bushman Tested by: Jan Beich MFC after: 1 week
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/net/nscachedcli.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/libc/net/nscachedcli.c b/lib/libc/net/nscachedcli.c
index 1323805..b4de0c1 100644
--- a/lib/libc/net/nscachedcli.c
+++ b/lib/libc/net/nscachedcli.c
@@ -75,9 +75,10 @@ safe_write(struct cached_connection_ *connection, const void *data,
nevents = _kevent(connection->write_queue, NULL, 0, &eventlist,
1, &timeout);
if ((nevents == 1) && (eventlist.filter == EVFILT_WRITE)) {
- s_result = _write(connection->sockfd, data + result,
+ s_result = _sendto(connection->sockfd, data + result,
eventlist.data < data_size - result ?
- eventlist.data : data_size - result);
+ eventlist.data : data_size - result, MSG_NOSIGNAL,
+ NULL, 0);
if (s_result == -1)
return (-1);
else
@@ -175,8 +176,8 @@ send_credentials(struct cached_connection_ *connection, int type)
nevents = _kevent(connection->write_queue, NULL, 0, &eventlist, 1,
NULL);
if (nevents == 1 && eventlist.filter == EVFILT_WRITE) {
- result = (_sendmsg(connection->sockfd, &cred_hdr, 0) == -1) ?
- -1 : 0;
+ result = (_sendmsg(connection->sockfd, &cred_hdr,
+ MSG_NOSIGNAL) == -1) ? -1 : 0;
EV_SET(&eventlist, connection->sockfd, EVFILT_WRITE, EV_ADD,
0, 0, NULL);
_kevent(connection->write_queue, &eventlist, 1, NULL, 0, NULL);
OpenPOWER on IntegriCloud