Home GnuPG
Diffusion GPGME b5b996b1a142

core: Restore get_max_fds optimization on Linux

Description

core: Restore get_max_fds optimization on Linux

* src/posix-io.c (get_max_fds): Restore Linux optimization, this time
using open/getdents/close rather than opendir/readdir/closedir.

opendir/readdir/closedir may allocate/free memory, and aren't required
to do so in an async-signal-safe way. On the other hand, opening
/proc/self/fd directly and iterating over it using getdents is safe.

(getdents is not strictly speaking documented to be async-signal-safe
because it's not in POSIX. However, the Linux implementation is
essentially just a souped-up read. Python >= 3.2.3 makes the same
assumption.)

  • Signed-off-by: Colin Watson <cjwatson@debian.org>

Details

Provenance
Colin Watson <cjwatson@debian.org>Authored on Sep 16 2017, 5:16 AM
wernerCommitted on Oct 4 2017, 5:26 PM
Parents
rMbff944842887: Register DCO for Colin Watson.
Branches
Unknown
Tags
Unknown