bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* accept4 and SOCK_NONBLOCK
@ 2019-08-20 15:27 Richard W.M. Jones
  2019-08-20 15:37 ` Florian Weimer
  2019-08-20 16:23 ` Eric Blake
  0 siblings, 2 replies; 6+ messages in thread
From: Richard W.M. Jones @ 2019-08-20 15:27 UTC (permalink / raw)
  To: Bruno Haible, bug-gnulib

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, SOCK_NONBLOCK|SOCK_CLOEXEC);

  https://github.com/libguestfs/libguestfs/blob/master/lib/launch-libvirt.c#L639

This is a valid set of flags according to the Linux man page for
accept4(2).  But it fails with EINVAL because of the following test in
gnulib:

  if ((flags & ~(SOCK_CLOEXEC | O_TEXT | O_BINARY)) != 0)
    {
      errno = EINVAL;
      return -1;
    }

  https://git.savannah.gnu.org/cgit/gnulib.git/tree/lib/accept4.c#n61

So I think the set of flags should be broadened to include
SOCK_NONBLOCK + add a call to set_nonblocking_flag.

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 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection  conftest.c >&5
  configure:25630: $? = 0
  configure:25630: result: yes

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-08-20 19:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-20 15:27 accept4 and SOCK_NONBLOCK Richard W.M. Jones
2019-08-20 15:37 ` Florian Weimer
2019-08-20 16:03   ` Richard W.M. Jones
2019-08-20 16:12     ` Florian Weimer
2019-08-20 16:23 ` Eric Blake
2019-08-20 19:28   ` Bruno Haible

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).