VM and non-blocking writes
Corinna Vinschen
corinna-cygwin@cygwin.com
Sun Dec 16 13:42:00 GMT 2007
On Dec 15 12:29, Robert Pendell wrote:
> Corinna Vinschen wrote:
> > Obviously I searched wrong. There a reports about this behaviour
> > since at least 1998 and it has never been fixed. These two links
> > might be interesting:
> >
> > http://support.microsoft.com/kb/q201213/
> > http://tinyurl.com/2brokp
>
> Do you have the test case you used for the pure win32 mode?
Sure, but before we start with this, a note:
I'm contemplating the idea to workaround this problem in Cygwin (not
for 1.5.25, but in the main trunk) by caping the number of bytes in a
single send call, according to the patch Lev sent in
http://www.cygwin.com/ml/cygwin-patches/2006-q2/msg00031.html.
Lev, are you interested in reworking your patch (minus the pipe stuff)
to match current CVS? Is there any gain in raising SO_SNDBUF/SO_RCVBUF
to a value > 8K, especially in the light of my experiences commented
on in net.cc, function fdsock()?
Back to the testcase. Source attached. I created it so that it can be
built as Cygwin or Linux executable
$ gcc -g -o nbcheck nbcheck.c
as well as native Windows application using mingw:
$ gcc -g -mno-cygwin -o nbcheck-nat nbcheck.c -lws2_32
It takes the size of the user data buffer as optional argument, defaulting
to 100,000,000 bytes.
> If you do
> then maybe I can try and push to get this fixed for the next service
> pack release for both XP and Vista as well as Server 2008. This will
> especially be the case if it can be easily reproduced.
Reproducing the issue is as easy as Wayne described. Just start a
client application which connects but never reads, for instance by using
the python sequence Wayne used in his mail:
$ python
import socket
s = socket.socket()
s.connect(("name-of-windows-box", 12345))
If you add a second arbitrary argument, the testcase tries to write
always in 10,000 bytes chunks. This shows how select starts to block at
one point, in my case on XP SP2 after writing 190,000 bytes.
Result on Linux:
$ ./nbcheck 500000000
listening to port 12345 host linux-box (10.0.0.1)
got connection from 10.0.0.3
accepted socket is nonblocking now
buffer size is 100000000 bytes
trying to write 100000000 bytes
65536 bytes written
trying to write 99934464 bytes
147456 bytes written
[HANG in select]
$ ./nbcheck 100000000
listening to port 12345 host linux-box (10.0.0.1)
got connection from 10.0.0.3
accepted socket is nonblocking now
buffer size is 100000000 bytes
trying to write 100000000 bytes
65536 bytes written
trying to write 99934464 bytes
147456 bytes written
[HANG in select]
$ ./nbcheck 100000000 x
listening to port 12345 host linux-box (10.0.0.1)
got connection from 10.0.0.3
accepted socket is nonblocking now
buffer size is 100000000 bytes
trying to write 10000 bytes
10000 bytes written
trying to write 10000 bytes
10000 bytes written
trying to write 10000 bytes
10000 bytes written
trying to write 10000 bytes
10000 bytes written
trying to write 10000 bytes
10000 bytes written
trying to write 10000 bytes
10000 bytes written
trying to write 10000 bytes
10000 bytes written
trying to write 10000 bytes
10000 bytes written
trying to write 10000 bytes
10000 bytes written
trying to write 10000 bytes
10000 bytes written
trying to write 10000 bytes
10000 bytes written
trying to write 10000 bytes
10000 bytes written
trying to write 10000 bytes
10000 bytes written
trying to write 10000 bytes
10000 bytes written
trying to write 10000 bytes
10000 bytes written
trying to write 10000 bytes
10000 bytes written
trying to write 10000 bytes
10000 bytes written
[HANG in select]
Result on Windows;
$ ./nbcheck-nat 500000000
listening to port 12345 host windows-box (10.0.0.2)
got connection from 10.0.0.3
accepted socket is nonblocking now
buffer size is 500000000 bytes
trying to write 500000000 bytes
Err: 10055
hit return to exit
$ ./nbcheck-nat 100000000
listening to port 12345 host windows-box (10.0.0.2)
got connection from 10.0.0.3
accepted socket is nonblocking now
buffer size is 100000000 bytes
trying to write 100000000 bytes
100000000 bytes written
hit return to exit
$ ./nbcheck-nat 100000000 x
listening to port 12345 host windows-box (10.0.0.2)
got connection from 10.0.0.3
accepted socket is nonblocking now
buffer size is 100000000 bytes
trying to write 10000 bytes
10000 bytes written
trying to write 10000 bytes
10000 bytes written
trying to write 10000 bytes
10000 bytes written
trying to write 10000 bytes
10000 bytes written
trying to write 10000 bytes
10000 bytes written
trying to write 10000 bytes
10000 bytes written
trying to write 10000 bytes
10000 bytes written
[WAIT in select for 5 seconds]
trying to write 10000 bytes
10000 bytes written
[WAIT in select for 14 seconds]
trying to write 10000 bytes
10000 bytes written
[WAIT in select for about 60 seconds]
trying to write 10000 bytes
10000 bytes written
[WAIT in select for about 60 seconds]
[a couple of times, but not always the same]
trying to write 10000 bytes
10000 bytes written
[HANG in select]
The hang occured in one testruns after 160,000 bytes, in another after
190,000 bytes. I have no idea if there's some sort of rule behind that.
> A source and > binary version will be useful for this.
Creating a binary is most easy, see above.
> I am in the tech beta group for
> Vista SP1, XP SP3, and Server 2008 so I can at least remind them of this
> bug and show them a test case. No guarantees that it will be fixed.
Actually, given that this behaviour is known since at least 10 years, I
doubt that it will even be accepted as a bug. But you never should give
up hope, right? :)
Thanks for your offer,
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Project Co-Leader cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nbcheck.c
Type: text/x-c++src
Size: 3154 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20071216/8a175030/attachment.bin>
-------------- next part --------------
--
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/
More information about the Cygwin
mailing list