Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 3 Jun 2012 11:31:45 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r236510 - stable/8/lib/libfetch
Message-ID:  <201206031131.q53BVjw9058407@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Sun Jun  3 11:31:45 2012
New Revision: 236510
URL: http://svn.freebsd.org/changeset/base/236510

Log:
  MFC r236193: libfetch: Avoid SIGPIPE on network connections.
  
  To avoid unexpected process termination from SIGPIPE when writing to a
  closed network connection, enable SO_NOSIGPIPE on all network connections.
  
  The POSIX standard MSG_NOSIGNAL is not used since it requires modifying all
  send calls to add this flag. This is particularly nasty for SSL connections.

Modified:
  stable/8/lib/libfetch/common.c
Directory Properties:
  stable/8/lib/libfetch/   (props changed)

Modified: stable/8/lib/libfetch/common.c
==============================================================================
--- stable/8/lib/libfetch/common.c	Sun Jun  3 11:29:48 2012	(r236509)
+++ stable/8/lib/libfetch/common.c	Sun Jun  3 11:31:45 2012	(r236510)
@@ -209,11 +209,13 @@ conn_t *
 fetch_reopen(int sd)
 {
 	conn_t *conn;
+	int opt = 1;
 
 	/* allocate and fill connection structure */
 	if ((conn = calloc(1, sizeof(*conn))) == NULL)
 		return (NULL);
 	fcntl(sd, F_SETFD, FD_CLOEXEC);
+	setsockopt(sd, SOL_SOCKET, SO_NOSIGPIPE, &opt, sizeof opt);
 	conn->sd = sd;
 	++conn->ref;
 	return (conn);



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