summaryrefslogtreecommitdiffstats
path: root/usr.sbin/portsnap
diff options
context:
space:
mode:
authorcperciva <cperciva@FreeBSD.org>2009-04-03 21:13:18 +0000
committercperciva <cperciva@FreeBSD.org>2009-04-03 21:13:18 +0000
commit8e78b05618b656bb96d7021fe2a806a2de1a99c7 (patch)
treec7f9098155be58bb1283adcf6539492c20295e99 /usr.sbin/portsnap
parentdabf12094da3c5011e4231e79889fac82747e961 (diff)
downloadFreeBSD-src-8e78b05618b656bb96d7021fe2a806a2de1a99c7.zip
FreeBSD-src-8e78b05618b656bb96d7021fe2a806a2de1a99c7.tar.gz
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
Diffstat (limited to 'usr.sbin/portsnap')
-rw-r--r--usr.sbin/portsnap/phttpget/phttpget.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/usr.sbin/portsnap/phttpget/phttpget.c b/usr.sbin/portsnap/phttpget/phttpget.c
index e109124..1bf6d9d 100644
--- a/usr.sbin/portsnap/phttpget/phttpget.c
+++ b/usr.sbin/portsnap/phttpget/phttpget.c
@@ -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);
OpenPOWER on IntegriCloud