This is the mail archive of the
mailing list for the Cygwin project.
Re: write big buffer to connected socket, then close socket hangs cygwin
- From: Corinna Vinschen <corinna-cygwin at cygwin dot com>
- To: cygwin at cygwin dot com
- Date: Tue, 15 Jul 2008 19:11:07 +0200
- Subject: Re: write big buffer to connected socket, then close socket hangs cygwin
- References: <email@example.com>
- Reply-to: cygwin at cygwin dot com
On Jul 15 17:35, kalle ko wrote:
> Latest updated cygwin (just updated to make sure), Windows Vista SP1.
> This will hang cygwin 1.5.25-cr-0x5f1:
> 1. Create a connected socket
> 2. Send a big enough buffer (> 0x4238 bytes)
> 3. Close the socket
> It will hang in the close() function. Only way is to kill it with
> taskmanager or close the cygwin window. Source code is attached.
Thanks for the testcase.
There's nothing in Cygwin's socket code which would make it dependent on
the buffer size given to the send() function.
Your scenario triggers the auto-linger in Cygwin's socket close()
function, which has been added many years ago to workaround a problem
with WinSock on application exit. For some reason the linger doesn't
timeout (which it should after about 4 minutes), as soon as the sent
buffer is bigger than this weird 0x4238. Since Cygwin doesn't handle
anything differently due to size, this looks like a WinSock problem we
just never encountered.
To fix this in your application, you should call shutdown(SHUT_WR)
before calling close(). This seems to be fixed in the next Cygwin
release 1.7 which doesn't linger in close anymore, but due to limited
testing it's still not entirely clear if that's ok now.
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Project Co-Leader cygwin AT cygwin DOT com
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html