Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 18 Nov 2000 14:27:44 +0300
From:      "Dmitry Sychov" <accelware@accelware.com>
To:        <freebsd-hackers@freebsd.org>
Subject:   close(), shutdown() behaviour when SO_LINGER is set.
Message-ID:  <002301c05153$0e84e620$edc030d4@dima>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.

------=_NextPart_000_0012_01C0516B.B70543E0
Content-Type: text/plain;
	charset="koi8-r"
Content-Transfer-Encoding: quoted-printable

Greetings!

I'am developing the single thread http server
which uses kqueue/kevent for both sockets
and async file reads. It works just fine and I thought
I 'd be able to do all the stuff with one thread until it
comes to proper socket closing.

As far as I understand the only way for server, working
with HTTP/1.0 client, to mark the data end is to close the
connection when the response was done. According to the
interface this does't mean that all the packets will arrive to the
client so one should set the socket option to SO_LINGER
and then call close() to be sure that all the packets are acknowledged
before closing the connection and make the OS handle the connection =
close.

The problem is, according to some posts, many systems
block the process on close() or shutdown() _when_ SO_LINGER is used.

My question is:  Does it safe to SO_LINGER with close() or shutdown() in =
FreeBSD 4.1+?
Will they block or not?

Thanks for all replies,
Dmitry

------=_NextPart_000_0012_01C0516B.B70543E0
Content-Type: text/html;
	charset="koi8-r"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>

<META content=3Dtext/html;charset=3Dkoi8-r http-equiv=3DContent-Type>
<META content=3D'"MSHTML 4.72.3110.7"' name=3DGENERATOR>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3D"Arial Cyr" size=3D2>Greetings!</FONT></DIV>
<DIV><FONT face=3D"Arial Cyr" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Arial Cyr" size=3D2>I'am developing the single thread =
http=20
server</FONT></DIV>
<DIV><FONT face=3D"Arial Cyr" size=3D2>which uses kqueue/kevent for both =

sockets</FONT></DIV>
<DIV><FONT face=3D"Arial Cyr" size=3D2>and async file reads. It works =
just fine and=20
I thought</FONT></DIV>
<DIV><FONT face=3D"Arial Cyr" size=3D2>I 'd be able to do all the stuff =
with one=20
thread until it</FONT></DIV>
<DIV><FONT face=3D"Arial Cyr" size=3D2>comes to proper socket =
closing.</FONT></DIV>
<DIV><FONT face=3D"Arial Cyr" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Arial Cyr" size=3D2>As far as I understand the only =
way for=20
server, working</FONT></DIV>
<DIV><FONT face=3D"Arial Cyr" size=3D2>with HTTP/1.0 client, to mark the =
data end is=20
to close the</FONT></DIV>
<DIV><FONT face=3D"Arial Cyr" size=3D2>connection when the response was =
done.=20
According to the</FONT></DIV>
<DIV><FONT face=3D"Arial Cyr" size=3D2>interface this does't mean that =
all the=20
packets will arrive to the</FONT></DIV>
<DIV><FONT face=3D"Arial Cyr" size=3D2>client so one should set the =
socket option to=20
SO_LINGER</FONT></DIV>
<DIV><FONT face=3D"Arial Cyr" size=3D2>and then call close() to =
</FONT><FONT=20
face=3D"Arial Cyr" size=3D2>be sure that all the packets are =
acknowledged<BR>before=20
closing the connection and </FONT><FONT face=3D"Arial Cyr" size=3D2>make =
the OS=20
handle the connection close.</FONT></DIV>
<DIV><FONT face=3D"Arial Cyr" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Arial Cyr" size=3D2>The problem is, according to some =
posts, many=20
systems</FONT></DIV>
<DIV><FONT face=3D"Arial Cyr" size=3D2>block the process on close() or =
shutdown()=20
_when_ SO_LINGER is used.</FONT></DIV>
<DIV><FONT face=3D"Arial Cyr" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Arial Cyr" size=3D2>My question is:&nbsp; Does it =
safe to=20
SO_LINGER with close() or shutdown() in FreeBSD 4.1+?</FONT></DIV>
<DIV><FONT face=3D"Arial Cyr" size=3D2>Will they block or =
not?</FONT></DIV>
<DIV><FONT face=3D"Arial Cyr" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Arial Cyr" size=3D2>Thanks for all =
replies,</FONT></DIV>
<DIV><FONT face=3D"Arial Cyr" size=3D2></FONT><FONT face=3D"Arial Cyr"=20
size=3D2>Dmitry</FONT></DIV></BODY></HTML>

------=_NextPart_000_0012_01C0516B.B70543E0--



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?002301c05153$0e84e620$edc030d4>