From owner-freebsd-hackers Tue Nov 21 19:38:25 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from mercury.illtel.denver.co.us (clw-5-CF5A06-144.wwc.com [207.90.6.144]) by hub.freebsd.org (Postfix) with ESMTP id 906E337B4D7 for ; Tue, 21 Nov 2000 19:38:21 -0800 (PST) Received: from localhost (abelits@localhost) by mercury.illtel.denver.co.us (8.9.3/8.9.3) with ESMTP id TAA01093; Tue, 21 Nov 2000 19:39:27 -0800 X-Authentication-Warning: mercury.illtel.denver.co.us: abelits owned process doing -bs Date: Tue, 21 Nov 2000 19:39:24 -0800 (PST) From: Alex Belits X-Sender: abelits@mercury To: Nicolai Petri Cc: freebsd-hackers@freebsd.org Subject: Re: SIGPIPE in multithread http server. In-Reply-To: <01ad01c0542c$5d4d38d0$6732a8c0@atomic.dk> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Wed, 22 Nov 2000, Nicolai Petri wrote: > I hope someone can help me with this issue.. > > When the application recieves a SIGPIPE the thread hangs hard.. What is the > correct thing to do when a socket is closed by the remote end ?? When application receives SIGPIPE the correct thing to do is nothing unless you have only one socket or pipe in the whole process -- and even then you shouldn't manipulate data used by the rest of program from inside the signal handler -- ignore the signal ot just set some flag from inside the handler. You can use this flag if it helps you to check if there is any socket that just got closed, however real test for closed socket while you are writing in it is failed write()/writev()/send()/... -- whatever you use to send the data to the other end. Of course, you should also check for empty read() result to see if the socket was closed while you was reading the request. When connection is closed on the other end you must close() it, and consider whatever was sent there to be lost. -- Alex To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message