This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: write big buffer to connected socket, then close socket hangs cygwin


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

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]