Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Mar 2003 11:30:02 +0200
From:      Peter Pentchev <roam@ringlet.net>
To:        net@FreeBSD.org
Cc:        Tristan Goode <tgoode@iprimus.com.au>
Subject:   write(2) SIGPIPE on a closed socket?
Message-ID:  <20030319093002.GT468@straylight.oblivion.bg>

index | next in thread | raw e-mail

[-- Attachment #1 --]
Hi,

In http://marc.theaimsgroup.com/?l=djbdns&m=104796742521473&w=2 and
http://marc.theaimsgroup.com/?l=djbdns&m=104802936220297&w=2 Tristan
Goode describes a weird problem on FreeBSD 4.5: a program (DJB's
dnscache) getting a SIGPIPE when attempting to write to an incoming
connection's socket.  Presumably, the client closed the connection in
the meantime, possibly due to a timeout; the funny part is that the
ktrace's show the following sequence of events:

line 320845:		accept() returns fd 170
line 320875-325758:	successive read()'s return data
line 325784:		a successful write() returns the full amount of
			data written
line 325794-328586:	more read()'s
line 328612:		another successful write()
(repeat a few more times, exactly the same pattern)
line 334354:		the last successful write()
line 334364-335002:	more read()'s, all successful
line 335028:		another attempted write()
line 335029:		PSIG SIGPIPE

The question: if the client closed the socket, shouldn't a write(2)
return -1 with errno == EPIPE before sending a SIGPIPE?  Does anyone
know anything about problems with writing to closed sockets in FreeBSD
4.5 or such?

A bzipped version of the tracefile is available at
http://people.FreeBSD.org/~roam/dnscache-ktrace.txt.bz2

G'luck,
Peter

-- 
Peter Pentchev	roam@ringlet.net    roam@sbnd.net    roam@FreeBSD.org
PGP key:	http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint	FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
because I didn't think of a good beginning of it.

[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (FreeBSD)

iD8DBQE+eDia7Ri2jRYZRVMRAgtHAKChd4gfAIaqX2vHBzcqohk85v75EwCfeiAX
DvIjje7srzUoSkmNZCEcPqc=
=wcwf
-----END PGP SIGNATURE-----
help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030319093002.GT468>