Date: Fri, 3 Apr 2009 21:13:18 +0000 (UTC) From: Colin Percival <cperciva@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r190679 - head/usr.sbin/portsnap/phttpget Message-ID: <200904032113.n33LDITC033195@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200904032113.n33LDITC033195>