> > 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

Attachment: shutdown.patch
Description: Binary data

Attachment: shutdown.ChangeLog
Description: Binary data

--
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/

Reply via email to