Re: [PATCH] accept4: Support SOCK_NONBLOCK, if defined

2019-08-20 Thread Eric Blake
On 8/20/19 2:29 PM, Bruno Haible wrote: > Eric Blake wrote: >> +#if SOCK_CLOEXEC >> + if (flags & SOCK_NONBLOCK) > > Why '#if SOCK_CLOEXEC'? > Why not '#if SOCK_NONBLOCK'? Because I made a typo. Thanks for spotting it; will fix shortly. -- Eric Blake, Principal Software Engineer Red Hat,

Re: [PATCH] accept4: Support SOCK_NONBLOCK, if defined

2019-08-20 Thread Bruno Haible
Eric Blake wrote: > Hmm, I guess it would be better to make the accept4 module depend on > nonblocking I would not like this. The 'nonblocking' module is quite intrusive (it hooks into many stdio functions, from 'getchar' to 'fprintf'). Few applications use nonblocking file, pipe, or sockets. The

Re: accept4 and SOCK_NONBLOCK

2019-08-20 Thread Bruno Haible
Eric Blake wrote: > #if HAVE_ACCEPT4 > > Aha - there's the bug. > > Commit e597d4b8 changed from AC_CHECK_FUNCS_ONCE (defines HAVE_ACCEPT4) > to AC_CHECK_DECLS (defines HAVE_DECL_ACCEPT4), but failed to update the > .c file. I'll push the obvious fix. Indeed. My mistake, sorry. Bruno

Re: [PATCH] accept4: Support SOCK_NONBLOCK, if defined

2019-08-20 Thread Bruno Haible
Eric Blake wrote: > +#if SOCK_CLOEXEC > + if (flags & SOCK_NONBLOCK) Why '#if SOCK_CLOEXEC'? Why not '#if SOCK_NONBLOCK'? Bruno

Re: [PATCH] accept4: Support SOCK_NONBLOCK, if defined

2019-08-20 Thread Richard W.M. Jones
On Tue, Aug 20, 2019 at 11:37:27AM -0500, Eric Blake wrote: > +#if SOCK_CLOEXEC > + if (flags & SOCK_NONBLOCK) > +{ > + int fcntl_flags; > + > + if ((fcntl_flags = fcntl (fd, F_GETFL, 0)) < 0 > + || fcntl (fd, F_SETFL, fcntl_flags | O_NONBLOCK) == -1) Can't this call

Re: [PATCH] accept4: Support SOCK_NONBLOCK, if defined

2019-08-20 Thread Eric Blake
On 8/20/19 11:37 AM, Eric Blake wrote: > Ideally, we would improve our replacement to define a > replacement SOCK_NONBLOCK on all platforms, and teach socket() to > honor it as well; but that's a bigger task. In the meantime, if the > platform already has SOCK_NONBLOCK, we should honor it when

[PATCH] accept4: Support SOCK_NONBLOCK, if defined

2019-08-20 Thread Eric Blake
+ accept4: Support SOCK_NONBLOCK, if defined + * lib/accept4.c (accept4): If SOCK_NONBLOCK is defined, honor it. + accept4: Fix compilation when native accept4() exists. Reported by Richard W.M. Jones in https://lists.gnu.org/archive/html/bug-gnulib/2019-08

Re: accept4 and SOCK_NONBLOCK

2019-08-20 Thread Eric Blake
On 8/20/19 10:27 AM, Richard W.M. Jones wrote: > First of all I'm using Linux 5.0.17 & glibc-2.29-15 so as far as I'm > aware accept4 exists and fully works and gnulib shouldn't be replacing > it at all. I don't understand why it's being replaced. > I think I'm reproducing your setup (Fedora

Re: accept4 and SOCK_NONBLOCK

2019-08-20 Thread Florian Weimer
* Richard W. M. Jones: > On Tue, Aug 20, 2019 at 05:37:58PM +0200, Florian Weimer wrote: >> * Richard W. M. Jones: >> >> > As for why accept4 is being replaced at all, the only reference to it >> > in config.log is: >> > >> > configure:25630: checking whether accept4 is declared >> >

Re: accept4 and SOCK_NONBLOCK

2019-08-20 Thread Richard W.M. Jones
On Tue, Aug 20, 2019 at 05:37:58PM +0200, Florian Weimer wrote: > * Richard W. M. Jones: > > > As for why accept4 is being replaced at all, the only reference to it > > in config.log is: > > > > configure:25630: checking whether accept4 is declared > > configure:25630: gcc -c -O2 -g -pipe

Re: accept4 and SOCK_NONBLOCK

2019-08-20 Thread Florian Weimer
* Richard W. M. Jones: > As for why accept4 is being replaced at all, the only reference to it > in config.log is: > > configure:25630: checking whether accept4 is declared > configure:25630: gcc -c -O2 -g -pipe -Wall -Werror=format-security > -Wp,-D_FORTIFY_SOURCE=2

accept4 and SOCK_NONBLOCK

2019-08-20 Thread Richard W.M. Jones
First of all I'm using Linux 5.0.17 & glibc-2.29-15 so as far as I'm aware accept4 exists and fully works and gnulib shouldn't be replacing it at all. I don't understand why it's being replaced. But given that, in libguestfs we call: r = accept4 (console_sock, NULL, NULL,