Re: non-blocking I/O tests

2011-04-18 Thread Eric Blake
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

Re: non-blocking I/O tests

2011-04-17 Thread Bruno Haible
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. 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

Re: non-blocking I/O tests

2011-04-15 Thread Eric Blake
On 04/10/2011 08:12 PM, Bruno Haible wrote: > Hi Eric, > > I was a bit suspicious whether non-blocking I/O on Woe32 sockets really work. > So I set out to write a unit test for it. Sockets are a bit more complicated > than pipes, so I started with the pipes. > > Find at

non-blocking I/O in pwrite

2011-04-13 Thread Bruno Haible
When a package uses the gnulib modules 'pwrite' and 'nonblocking', it ought to get a pwrite() function that works on non-blocking file descriptors. This implements it. 2011-04-13 Bruno Haible Support non-blocking pipe I/O and SIGPIPE in pwrite(). * modules/pwrite (Depends-on):

non-blocking I/O tests

2011-04-10 Thread Bruno Haible
Hi Eric, I was a bit suspicious whether non-blocking I/O on Woe32 sockets really work. So I set out to write a unit test for it. Sockets are a bit more complicated than pipes, so I started with the pipes. Find attached this unit test - for testing, not yet ready to be committed -. Can you

Re: non-blocking I/O

2011-03-31 Thread Bruno Haible
Hi Eric, Thanks for taking up and improving on my proposal. > > - use select() or poll() followed by read() or write() if the > > descriptor > >is ready, > > - call read() or write() in separate threads. */ > > - use aio_*, although that is not as widely portable Yes, good p

Re: non-blocking I/O

2011-03-30 Thread Paolo Bonzini
On 03/30/2011 07:46 PM, Eric Blake wrote: I'm not sure whether block and character special devices can usefully be set non-blocking I believe at least /dev/random supports it: #include #include #include #include int main() { char buf[256]; int fd = open ("/dev/random", O_RDONLY | O_NON

Re: non-blocking I/O

2011-03-30 Thread Eric Blake
On 03/30/2011 11:46 AM, Eric Blake wrote: > On 03/29/2011 09:16 AM, Bruno Haible wrote: >> Paolo Bonzini wrote: >>> Without guessing what your bias is, I also :) prefer to implement >>> {g,s}et_nonblock_flag functions. It would use either >>> SetNamedPipeHandleState or ioctlsocket (using the soc

Re: non-blocking I/O

2011-03-30 Thread Eric Blake
> in sockets.c to detect sockets, and then GetFileType to detect pipes if >> it fails). > > Here's proposed code to that effect. Let's get it checked in. > Note that the getter function cannot > be implemented: How to determine whether a Woe32 socket is non-blockin

Re: non-blocking I/O

2011-03-29 Thread Bastien ROUCARIES
with WSAEINVAL. >> >> To set the socket back to blocking mode, an application must first >> disable WSAEventSelect by calling WSAEventSelect with the >> lNetworkEvents parameter equal to zero. >> >> Using this trick will allow to ask the socket (but not thread safe :S) &

Re: non-blocking I/O

2011-03-29 Thread Bastien ROUCARIES
is trick will allow to ask the socket (but not thread safe :S) I am stupid It will not work Bastien > > Bastien > >> >> >> nonblocking.h >> >> /* Non-blocking I/O for pipe or socket descriptors. >>   Copyright (C) 2011 Free Softw

Re: non-blocking I/O

2011-03-29 Thread Bastien ROUCARIES
e WSAEventSelect by calling WSAEventSelect with the lNetworkEvents parameter equal to zero. Using this trick will allow to ask the socket (but not thread safe :S) Bastien > > > nonblocking.h > > /* Non-blocking I

Re: non-blocking I/O

2011-03-29 Thread Bruno Haible
ect pipes if > it fails). Here's proposed code to that effect. Note that the getter function cannot be implemented: How to determine whether a Woe32 socket is non-blocking? nonblocking.h ======== /* Non-blocking I/O for pipe o

Re: non-blocking I/O on Woe32

2011-03-29 Thread Bruno Haible
Eric Blake wrote: > Mingw has named pipes, but they appear to > reside in a different namespace than the normal file system, and the > gnulib mkfifo() implementation current always fails with ENOSYS on > mingw. Unless we find a way to expose named pipes in the normal file > system on mingw, then y

Re: non-blocking I/O

2011-03-29 Thread Eric Blake
On 03/29/2011 06:45 AM, Eric Blake wrote: > Mingw supports named pipes (witness the mkfifo gnulib function), Oops, hit send too soon. Mingw has named pipes, but they appear to reside in a different namespace than the normal file system, and the gnulib mkfifo() implementation current always fails

Re: non-blocking I/O

2011-03-29 Thread Bastien ROUCARIES
vertheless in gnulib we try to offer the POSIX APIs, if possible. > > There are three APIs for non-blocking I/O on Unix: >  1) fcntl F_SETFL O_NONBLOCK  (POSIX, SysV) >  2) fcntl F_SETFL O_NDELAY  (older SysV) >  3) ioctl FIONBIO  (BSD 4.2) 4) SOCK_NONBLOCKL Bastien > According t

Re: non-blocking I/O

2011-03-29 Thread Eric Blake
t) or ioctl FIONBIO. > > So, barring bugs that we find during unit testing, we need > - a replacement for fcntl F_SETFL O_NONBLOCK that supports mingw, > - extend lib/open.c so that it handles O_NONBLOCK on mingw (presumably > by failing, because Win32 does not support non-

Re: non-blocking I/O

2011-03-29 Thread Bruno Haible
rts mingw, - extend lib/open.c so that it handles O_NONBLOCK on mingw (presumably by failing, because Win32 does not support non-blocking I/O on regular files). I agree that get/set_nonblocking functions are a good step towards this. Bruno -- In memoriam Rachel Levy <http://en.wikipe