diff options
| author | Tobias Bucher <tobiasbucher5991@gmail.com> | 2018-05-14 13:20:39 +0200 |
|---|---|---|
| committer | Tobias Bucher <tobiasbucher5991@gmail.com> | 2018-05-14 13:20:39 +0200 |
| commit | 6d1da8232997af4b785486329f01995440818920 (patch) | |
| tree | 8d486cb8a4e0f941ce164dafd45787c79d11c53f /src/rustllvm/RustWrapper.cpp | |
| parent | 9e3caa23f99816caf3c2fb69ff5c88b512fb1b38 (diff) | |
| download | rust-6d1da8232997af4b785486329f01995440818920.tar.gz rust-6d1da8232997af4b785486329f01995440818920.zip | |
Don't unconditionally set CLOEXEC twice on every fd we open on Linux
Previously, every `open64` was accompanied by a `ioctl(…, FIOCLEX)`, because some old Linux version would ignore the `O_CLOEXEC` flag we pass to the `open64` function. Now, we check whether the `CLOEXEC` flag is set on the first file we open – if it is, we won't do extra syscalls for every opened file. If it is not set, we fall back to the old behavior of unconditionally calling `ioctl(…, FIOCLEX)` on newly opened files. On old Linuxes, this amounts to one extra syscall per process, namely the `fcntl(…, F_GETFD)` call to check the `CLOEXEC` flag. On new Linuxes, this reduces the number of syscalls per opened file by one, except for the first file, where it does the same number of syscalls as before (`fcntl(…, F_GETFD)` to check the flag instead of `ioctl(…, FIOCLEX)` to set it).
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
