[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: non-blocking I/O tests
From: |
Eric Blake |
Subject: |
Re: non-blocking I/O tests |
Date: |
Mon, 18 Apr 2011 06:59:05 -0600 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.15) Gecko/20110307 Fedora/3.1.9-0.39.b3pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.9 |
On 04/17/2011 12:15 PM, Bruno Haible wrote:
> Hi Eric,
>
> There were indeed some mistakes in the test. Now I've debugged it and added a
> test for non-blocking sockets as well.
Thanks again for tackling all of this.
>
> As is, the socket test fails on Cygwin 1.5.x. After putting STDOUT_FILENO in
> non-blocking mode, get_nonblocking_flag reports that it is in non-blocking
> mode,
> but it still behaves like a blocking socket. (You can convince yourself by
> setting ENABLE_DEBUGGING to 1 and doing
> "make check TESTS=test-nonblocking-socket.sh".)
> I don't know how to work around this, so I just put a comment in the test.
I'm not sure either, and cygwin 1.5 is starting to get old enough that
maybe we need not worry about it much longer.
>
> Another complication was that on Linux (and similarly on MacOS X and Windows),
> a writer can send much more data to a socket than the values of SO_SNDBUF and
> SO_RCVBUF indicate. These values are 128 KB or less, yet it is possible for
> a write() call of 7 MB of data on a supposedly blocking socket to succeed
> immediately, before the reader has requested to read this data.
>
> Yes another complication is that on Cygwin 1.5.x, writes of more than 64 MB
> fail with error ENOBUFS. While POSIX allows this failure, it is not clear to
> me whether it would not be better to implement in the module 'safe-write'
> or 'full-write' a logic that sends the data in pieces?
Indeed. Cygwin 1.7.9 ended up resorting to chunked read/write under the
hood, since Windows in general has problem with pipes if you ever try to
send more than 64k chunks (it would sometimes, but not always, work). I
definitely think that it's better to just document that write() is not
always reliable on super-large buffers, and to use safewrite() if the
goal is to send large buffers with under-the-hood chunking as necessary.
--
Eric Blake address@hidden +1-801-349-2682
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature