Mail Archives: cygwin/2002/03/20/09:05:37
------=_NextPart_000_00F1_01C1D020.08407F20
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
> > To my great surprise, the close(socket) operation
> > took EXTREMELY long. It
> > took 0.11 second (CPU usage was low), while this
> > operation under MinGW 1.1
> > on the same machine took only 0.00019 second. On
> > another Linux machine,
> > close took 0.000043 second.
> >
A solution may be in calling shutdown() if not called before
by the application before calling closesocket().
I have tried like this with success.
-- without shutdown() ----
accept: 0.000000
recv: 0.011112
send: 0.000069
shutdown: 0.000000
close: 0.328966
-- with shutdown(s,SHUT_WR) ----
accept: 0.000000
recv: 0.012169
send: 0.000089
shutdown: 0.000112
close: 0.000105
Question: Does adding shutdown make the following code
obsolate ? (I have assumed so in my appended patch)
fhandler_socket::close()
---old---
/* HACK to allow a graceful shutdown even if shutdown()
hasn't been
called by the application. Note that this isn't the
ultimate
solution but it helps in many cases. */
struct linger linger;
linger.l_onoff = 1;
linger.l_linger = 240; /* seconds. default 2MSL value
according to MSDN. */
setsockopt (get_socket (), SOL_SOCKET, SO_LINGER,
(const char *)&linger, sizeof linger);
--new----
if (!saw_shutdown_read () && !saw_shutdown_write ())
shutdown(get_socket (),SD_BOTH);
---------
Any comments to this ? What about win95 and other os. Could
there be any problems ?
Regards
Ralf
------=_NextPart_000_00F1_01C1D020.08407F20
Content-Type: application/octet-stream;
name="shutdown.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="shutdown.patch"
Index: fhandler_socket.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cygwin/fhandler_socket.cc,v=0A=
retrieving revision 1.41=0A=
diff -u -p -r1.41 fhandler_socket.cc=0A=
--- fhandler_socket.cc 2002/03/05 18:02:53 1.41=0A=
+++ fhandler_socket.cc 2002/03/20 11:30:36=0A=
@@ -343,14 +343,8 @@ fhandler_socket::close ()=0A=
int res =3D 0;=0A=
sigframe thisframe (mainthread);=0A=
=0A=
- /* HACK to allow a graceful shutdown even if shutdown() hasn't been=0A=
- called by the application. Note that this isn't the ultimate=0A=
- solution but it helps in many cases. */=0A=
- struct linger linger;=0A=
- linger.l_onoff =3D 1;=0A=
- linger.l_linger =3D 240; /* seconds. default 2MSL value according to =
MSDN. */=0A=
- setsockopt (get_socket (), SOL_SOCKET, SO_LINGER,=0A=
- (const char *)&linger, sizeof linger);=0A=
+ if (!saw_shutdown_read () && !saw_shutdown_write ())=0A=
+ shutdown(get_socket (),SD_BOTH); =0A=
=0A=
while ((res =3D closesocket (get_socket ())) !=3D 0)=0A=
{=0A=
------=_NextPart_000_00F1_01C1D020.08407F20
Content-Type: application/octet-stream;
name="shutdown.ChangeLog"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="shutdown.ChangeLog"
2002-03-19 Ralf Habacker <Ralf DOT Habacker AT freenet DOT de>
* fhandler_socket.cc (fhandler_socket::close): Added call
to shutdown() in cases not called before to avoid delays.
------=_NextPart_000_00F1_01C1D020.08407F20
Content-Type: text/plain; charset=us-ascii
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
------=_NextPart_000_00F1_01C1D020.08407F20--
- Raw text -