Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Apr 2009 15:45:03 +0000 (UTC)
From:      Colin Percival <cperciva@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
Subject:   svn commit: r190778 - in stable/7/usr.sbin/portsnap: . phttpget
Message-ID:  <200904061545.n36Fj3nB075911@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: cperciva
Date: Mon Apr  6 15:45:03 2009
New Revision: 190778
URL: http://svn.freebsd.org/changeset/base/190778

Log:
  MFC r190679: Set SO_NOSIGPIPE on sockets in order to avoid having
  phttpget die when a RST packet arrives.
  
  Approved by:	re (kib)

Modified:
  stable/7/usr.sbin/portsnap/   (props changed)
  stable/7/usr.sbin/portsnap/phttpget/phttpget.c

Modified: stable/7/usr.sbin/portsnap/phttpget/phttpget.c
==============================================================================
--- stable/7/usr.sbin/portsnap/phttpget/phttpget.c	Mon Apr  6 15:29:44 2009	(r190777)
+++ stable/7/usr.sbin/portsnap/phttpget/phttpget.c	Mon Apr  6 15:45:03 2009	(r190778)
@@ -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?200904061545.n36Fj3nB075911>