Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Nov 2000 19:39:24 -0800 (PST)
From:      Alex Belits <abelits@phobos.illtel.denver.co.us>
To:        Nicolai Petri <nicolai@petri.cc>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: SIGPIPE in multithread http server.
Message-ID:  <Pine.LNX.4.10.10011211926560.1035-100000@mercury>
In-Reply-To: <01ad01c0542c$5d4d38d0$6732a8c0@atomic.dk>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.LNX.4.10.10011211926560.1035-100000>