mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-04 13:29:51 -05:00
os: wrap accept4(SOCK_CLOEXEC)
Some system C libraries do not have SOCK_CLOEXEC, and completely miss accept4(), too. Provide a fallback for this case. This changes the behaviour: no error messages are printed now for failing to set CLOEXEC but the file descriptor is closed. The unit test for this wrapper is NOT included. Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
This commit is contained in:
parent
b2eaf870cf
commit
ff50f6bfc4
5 changed files with 29 additions and 8 deletions
|
|
@ -902,14 +902,8 @@ socket_data(int fd, uint32_t mask, void *data)
|
|||
int client_fd;
|
||||
|
||||
length = sizeof name;
|
||||
client_fd =
|
||||
accept4(fd, (struct sockaddr *) &name, &length, SOCK_CLOEXEC);
|
||||
if (client_fd < 0 && errno == ENOSYS) {
|
||||
client_fd = accept(fd, (struct sockaddr *) &name, &length);
|
||||
if (client_fd >= 0 && fcntl(client_fd, F_SETFD, FD_CLOEXEC) == -1)
|
||||
fprintf(stderr, "failed to set FD_CLOEXEC flag on client fd, errno: %d\n", errno);
|
||||
}
|
||||
|
||||
client_fd = wl_os_accept_cloexec(fd, (struct sockaddr *) &name,
|
||||
&length);
|
||||
if (client_fd < 0)
|
||||
fprintf(stderr, "failed to accept, errno: %d\n", errno);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue