Date: Thu, 26 Dec 1996 02:40:32 +1100 (EST) From: Douglas Thomas Crosher <dtc@scrooge.ee.swin.oz.au> To: current@FreeBSD.org Subject: Invalid Argument error writing to closed socket. Message-ID: <199612251540.CAA19656@scrooge.ee.swin.oz.au>
next in thread | raw e-mail | index | archive | help
I've been tracking a problem which occcurs when writing to a TCP
socket for which the remote end has closed the connection - a write
returns an Invalid Argument error, however I suspect that it should
signal SIGPIPE. The relevant parts of a ktrace are included below. If
anyone has any ideas I'd be grateful for some help.
This is for a http server which persistent connections. Trouble occurs
because the server thinks the connection is still live - I'm currently
using getpeername to check. Is there a better more reliable way to
determine if the connection is still live?
Running FreeBSD-current 24/12/96.
Regards
Douglas Crosher
-=-=-=-
>From a ktrace log:
At this point file descriptor 6 is a TCP socket, and the other end has
closed the connection.
A read returns 0 bytes i.e. EOF.
198 lisp CALL read(0x6,0x803b000,0x1000)
198 lisp GIO fd 6 read 0 bytes
""
198 lisp RET read 0
getpeername is not aware the connection is closed yet.
198 lisp CALL getpeername(0x6,0xefbfd8b0,0xefbfd8ac)
198 lisp RET getpeername 0
The next write returns an Invalid Argument error. However I'm
confident that all the arguments are valid. Since the remote
connection has closed the connection I expected a SIGPIPE error.
198 lisp CALL write(0x6,0x8040000,0x8d)
198 lisp RET write -1 errno 22 Invalid argument <<<<<<<
The next write does give a SIGPIPE:
198 lisp CALL write(0x6,0x8040000,0x14)
198 lisp PSIG SIGPIPE caught handler=0x5564 mask=0x0 code=0x0
198 lisp RET write -1 errno 32 Broken pipe
-=-=-=-=-
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199612251540.CAA19656>
