Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Mar 2013 18:38:18 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r248252 - head/lib/libc/net
Message-ID:  <201303131838.r2DIcIsm031501@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Wed Mar 13 18:38:18 2013
New Revision: 248252
URL: http://svnweb.freebsd.org/changeset/base/248252

Log:
  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

Modified:
  head/lib/libc/net/nscachedcli.c

Modified: head/lib/libc/net/nscachedcli.c
==============================================================================
--- head/lib/libc/net/nscachedcli.c	Wed Mar 13 18:19:33 2013	(r248251)
+++ head/lib/libc/net/nscachedcli.c	Wed Mar 13 18:38:18 2013	(r248252)
@@ -75,9 +75,10 @@ safe_write(struct cached_connection_ *co
 		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_connectio
 	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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201303131838.r2DIcIsm031501>