From owner-svn-src-head@FreeBSD.ORG Fri Apr 3 21:13:18 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9ABA71065672; Fri, 3 Apr 2009 21:13:18 +0000 (UTC) (envelope-from cperciva@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 887878FC26; Fri, 3 Apr 2009 21:13:18 +0000 (UTC) (envelope-from cperciva@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n33LDIhn033196; Fri, 3 Apr 2009 21:13:18 GMT (envelope-from cperciva@svn.freebsd.org) Received: (from cperciva@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n33LDITC033195; Fri, 3 Apr 2009 21:13:18 GMT (envelope-from cperciva@svn.freebsd.org) Message-Id: <200904032113.n33LDITC033195@svn.freebsd.org> From: Colin Percival Date: Fri, 3 Apr 2009 21:13:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r190679 - head/usr.sbin/portsnap/phttpget X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Apr 2009 21:13:19 -0000 Author: cperciva Date: Fri Apr 3 21:13:18 2009 New Revision: 190679 URL: http://svn.freebsd.org/changeset/base/190679 Log: Set SO_NOSIGPIPE on sockets used by phttpget. Without this, if (1) phttpget is attempting to download enough files that it can't send all the requests at once, and (2) the remote server forcibly closes the connection, resulting in RST packets being sent, phttpget will receive a SIGPIPE and terminate without downloading all of the files. This is probably responsible for a number of hard-to-reproduce errors with portsnap and freebsd-update. MFC after: 3 days Modified: head/usr.sbin/portsnap/phttpget/phttpget.c Modified: head/usr.sbin/portsnap/phttpget/phttpget.c ============================================================================== --- head/usr.sbin/portsnap/phttpget/phttpget.c Fri Apr 3 20:46:32 2009 (r190678) +++ head/usr.sbin/portsnap/phttpget/phttpget.c Fri Apr 3 21:13:18 2009 (r190679) @@ -317,6 +317,7 @@ main(int argc, char *argv[]) int chunked; /* != if transfer-encoding is chunked */ off_t clen; /* Chunk length */ int firstreq = 0; /* # of first request for this connection */ + int val; /* Value used for setsockopt call */ /* Check that the arguments are sensible */ if (argc < 2) @@ -370,6 +371,11 @@ main(int argc, char *argv[]) setsockopt(sd, SOL_SOCKET, SO_RCVTIMEO, (void *)&timo, (socklen_t)sizeof(timo)); + /* ... disable SIGPIPE generation ... */ + val = 1; + setsockopt(sd, SOL_SOCKET, SO_NOSIGPIPE, + (void *)&val, sizeof(int)); + /* ... and connect to the server. */ if(connect(sd, res->ai_addr, res->ai_addrlen)) { close(sd);