public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: OpenSSL problem ? (Was Re: Pine 4.58 for Cygwin takes a very long time to close a certain IMAP INBOX)
Date: Wed, 12 Nov 2003 18:34:00 -0000	[thread overview]
Message-ID: <20031112183422.GE18706@cygbert.vinschen.de> (raw)
In-Reply-To: <Pine.CYG.4.58.0311121610400.3216@pervalidus>

On Wed, Nov 12, 2003 at 04:15:46PM -0200, Fr?d?ric L. W. Meunier wrote:
> On Wed, 12 Nov 2003, Brian Ford wrote:
> 
> > Corinna,
> >
> > Did you get a chance to look at the strace output he posted here:
> >
> > http://pervalidus.port5.com/tmp/imap.txt.gz
> >
> > A glance there by trained eyes might save him some time.  I don't have the
> > time or the training for mine :).  It appears to be stuck in close on the
> > socket after is has shutdown?
> 
> It seems to be cause by the firewall from my SpeedStream 5200.
> 
> 'a logout' worked once I disabled filtering 'TCP NULL', but the
> Pine delays remain.
> 
> Anyway, why it worked on plain Windows and Linux is another
> story. I don't have any other firewalls enabled.

fhandler_socket::close() tries to circumvent problems with unexpected
data loss which can occur, if an application exits without having
waited for the closesocket() call being successful.  The problem with
the latter is, that there's no way to find out.  Therefore Cygwin
lingers on closesocket(), even with non-blocking sockets.  I don't
know if that helps but you could try to build a Cygwin DLL which only
lingers if shutdown hasn't been called.  I tried it with ssh and it
seems at least not to disturb ssh operation.  Patch below.

Corinna

Index: fhandler_socket.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/fhandler_socket.cc,v
retrieving revision 1.111
diff -u -p -r1.111 fhandler_socket.cc
--- fhandler_socket.cc	25 Sep 2003 03:51:50 -0000	1.111
+++ fhandler_socket.cc	12 Nov 2003 18:32:18 -0000
@@ -1101,14 +1101,17 @@ fhandler_socket::close ()
 {
   int res = 0;
 
-  /* 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);
+  if (!saw_shutdown_write ())
+    {
+      /* 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; /* secs. default 2MSL value according to MSDN. */
+      setsockopt (get_socket (), SOL_SOCKET, SO_LINGER,
+		  (const char *)&linger, sizeof linger);
+    }
 
   while ((res = closesocket (get_socket ())) != 0)
     {


-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin@cygwin.com
Red Hat, Inc.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

  reply	other threads:[~2003-11-12 18:34 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-09 23:17 Pine 4.58 for Cygwin takes a very long time to close a certain IMAP INBOX Frédéric L. W. Meunier
2003-11-10  0:12 ` Eduardo Chappa
     [not found]   ` <Pine.CYG.4.58.0311092224530.572@pervalidus>
     [not found]     ` <Pine.OSF.4.58.0311100827250.430051@goedel.math.washington.edu>
     [not found]       ` <Pine.CYG.4.58.0311101454270.264@pervalidus>
     [not found]         ` <Pine.CYG.4.58.0311101932570.904@edocomputer>
     [not found]           ` <Pine.CYG.4.58.0311102345290.1728@pervalidus>
     [not found]             ` <Pine.CYG.4.58.0311102002280.908@edocomputer>
     [not found]               ` <Pine.CYG.4.58.0311110048230.1144@pervalidus>
     [not found]                 ` <Pine.OSF.4.58.0311101909180.444097@goedel.math.washington.edu>
     [not found]                   ` <Pine.CYG.4.58.0311110113180.3288@pervalidus>
     [not found]                     ` <Pine.OSF.4.58.0311101938000.444097@goedel.math.washington.edu>
2003-11-11  3:52                       ` OpenSSL problem ? (Was Re: Pine 4.58 for Cygwin takes a very long time to close a certain IMAP INBOX) Frédéric L. W. Meunier
2003-11-11 15:29                         ` Corinna Vinschen
2003-11-11 16:31                           ` Frédéric L. W. Meunier
2003-11-11 17:24                             ` Brian Ford
2003-11-11 17:57                               ` Frédéric L. W. Meunier
2003-11-11 18:12                               ` Frédéric L. W. Meunier
2003-11-12  2:21                                 ` Frédéric L. W. Meunier
2003-11-12  9:35                                   ` Corinna Vinschen
2003-11-12 14:07                                     ` Frédéric L. W. Meunier
2003-11-12 17:55                                       ` Brian Ford
2003-11-12 18:15                                         ` Frédéric L. W. Meunier
2003-11-12 18:34                                           ` Corinna Vinschen [this message]
2003-11-12 19:44                                             ` Frédéric L. W. Meunier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20031112183422.GE18706@cygbert.vinschen.de \
    --to=corinna-cygwin@cygwin.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).