Author: jilles
Date: Mon May 28 19:22:23 2012
New Revision: 236193
URL: http://svn.freebsd.org/changeset/base/236193

Log:
  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.
  
  Reviewed by:  des
  Tested by:    bapt
  MFC after:    5 days

Modified:
  head/lib/libfetch/common.c

Modified: head/lib/libfetch/common.c
==============================================================================
--- head/lib/libfetch/common.c  Mon May 28 19:13:21 2012        (r236192)
+++ head/lib/libfetch/common.c  Mon May 28 19:22:23 2012        (r236193)
@@ -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);
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to