From owner-freebsd-net Wed May 9 8: 9: 9 2001 Delivered-To: freebsd-net@freebsd.org Received: from sentry.granch.com (sentry.granch.com [212.109.197.55]) by hub.freebsd.org (Postfix) with ESMTP id 76C0637B422 for ; Wed, 9 May 2001 08:09:05 -0700 (PDT) (envelope-from shelton@sentry.granch.ru) Received: from sentry.granch.com (localhost [127.0.0.1]) by sentry.granch.com (8.11.3/8.11.3) with SMTP id f49F8UD06040; Wed, 9 May 2001 22:08:35 +0700 (NOVST) (envelope-from shelton@sentry.granch.ru) Content-Type: text/plain; charset="koi8-r" From: "Rashid N. Achilov" Reply-To: achilov@granch.ru Organization: Granch Ltd. To: Garrett Wollman , "Jonathan Graehl" Subject: Re: Do I need to close after shutdown if I don't want to leak descriptors? (making sure TCP retransmits all my data) Date: Wed, 9 May 2001 22:08:29 +0700 X-Mailer: KMail [version 1.2] Cc: References: <000001c0d6d5$87607e80$6dfeac40@straylight.com> <200105081923.PAA64300@khavrinen.lcs.mit.edu> In-Reply-To: <200105081923.PAA64300@khavrinen.lcs.mit.edu> MIME-Version: 1.0 Message-Id: <01050922082909.02773@sentry.granch.com> Content-Transfer-Encoding: 8bit Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org On Wednesday 09 May 2001 02:23, Garrett Wollman wrote: > < 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