os: wrap SOCK_CLOEXEC

Signed-off-by: Weijia Wang <contact@weijia.wang>
This commit is contained in:
Weijia Wang 2022-07-28 01:37:50 +02:00
parent 60827b862e
commit fe70c799e5
6 changed files with 44 additions and 10 deletions

View file

@ -92,10 +92,12 @@ socket(int domain, int type, int protocol)
{
wrapped_calls_socket++;
#ifdef SOCK_CLOEXEC
if (fall_back && (type & SOCK_CLOEXEC)) {
errno = EINVAL;
return -1;
}
#endif
return real_socket(domain, type, protocol);
}
@ -179,7 +181,11 @@ do_os_wrappers_socket_cloexec(int n)
* Must have 2 calls if falling back, but must also allow
* falling back without a forced fallback.
*/
#ifdef SOCK_CLOEXEC
assert(wrapped_calls_socket > n);
#else
assert(wrapped_calls_socket == 1);
#endif
exec_fd_leak_check(nr_fds);
}
@ -253,8 +259,8 @@ struct marshal_data {
static void
setup_marshal_data(struct marshal_data *data)
{
assert(socketpair(AF_UNIX,
SOCK_STREAM | SOCK_CLOEXEC, 0, data->s) == 0);
assert(wl_os_socketpair_cloexec(AF_UNIX,
SOCK_STREAM, 0, data->s) == 0);
data->read_connection = wl_connection_create(data->s[0]);
assert(data->read_connection);