Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 May 2001 22:08:29 +0700
From:      "Rashid N. Achilov" <shelton@sentry.granch.ru>
To:        Garrett Wollman <wollman@khavrinen.lcs.mit.edu>, "Jonathan Graehl" <jonathan@graehl.org>
Cc:        <freebsd-net@FreeBSD.ORG>
Subject:   Re: Do I need to close after shutdown if I don't want to leak descriptors? (making sure TCP retransmits all my data)
Message-ID:  <01050922082909.02773@sentry.granch.com>
In-Reply-To: <200105081923.PAA64300@khavrinen.lcs.mit.edu>
References:  <000001c0d6d5$87607e80$6dfeac40@straylight.com> <200105081923.PAA64300@khavrinen.lcs.mit.edu>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
On Wednesday 09 May 2001 02:23, Garrett Wollman wrote:
> <<On Mon, 7 May 2001 02:10:14 -0700, "Jonathan Graehl" 
<jonathan@graehl.org> said:
> > Problem: close() does not perform an orderly shutdown, does not resend
> > unacknowledged data - responds with RST to data/acks sent to me
>
> I suggest that this is a bug.

WinDoze do so. When connection finished, it sends RST instead FIN :-) But it 
isn't good. shutdown() should be called before close().

>
> > Incomplete solution: shutdown(SHUT_RDWR), but then what?  Will the OS
> > close the fd for me once the other end acknowledges, or better yet,
> > closes its end as well, or do I need to close the fd?
>
> No, you still have to close.

Yes, you still should close. shutdown() marks socket as "unusable for 
read/write/all" but don't free socket handle.

>
> > (selecting for readable is not a solution; if they have
> > sent me data I am uninterested in reading, I will select readable)
>
> selecting for an exception *should* do what you want, but doesn't
> (this is also a bug).
>
> > Obviously, if shutdown fails (it shouldn't, I die on failure), you would
> > need to close to avoid descriptor leakage.  But do I need to babysit the
> > descriptor after I have no more interest in it?
>
> Yes.  shutdown != close.

I have set flag 'close-on-exec' when open socket, because when I accept new 
connetcion, daemon forked. And have called shutdown() BEFORE close().
-- 
   With Best Regards.
   Rashid N. Achilov (RNA1-RIPE), Web: http://granch.ru/~shelton
   Granch Ltd. system administrator, e-mail: achilov@granch.ru
   PGP: 83 CD E2 A7 37 4A D5 81 D6 D6 52 BF C9 2F 85 AF 97 BE CB 0A

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-net" in the body of the message




Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?01050922082909.02773>