server: use the right client_fd

After accept, we transfered ownership of the client_fd to the source so
use the fd on the new owner.
This commit is contained in:
Wim Taymans 2026-04-30 10:00:53 +02:00
parent 4a34da368e
commit 57c621e654

View file

@ -447,10 +447,10 @@ on_connect(void *data, int fd, uint32_t mask)
#ifdef SO_PRIORITY #ifdef SO_PRIORITY
val = 6; val = 6;
if (setsockopt(client_fd, SOL_SOCKET, SO_PRIORITY, &val, sizeof(val)) < 0) if (setsockopt(client->source->fd, SOL_SOCKET, SO_PRIORITY, &val, sizeof(val)) < 0)
pw_log_warn("setsockopt(SO_PRIORITY) failed: %m"); pw_log_warn("setsockopt(SO_PRIORITY) failed: %m");
#endif #endif
pid = get_client_pid(client, client_fd); pid = get_client_pid(client, client->source->fd);
if (pid != 0 && pw_check_flatpak(pid, &app_id, &instance_id, &devices) == 1) { if (pid != 0 && pw_check_flatpak(pid, &app_id, &instance_id, &devices) == 1) {
/* /*
* XXX: we should really use Portal client access here * XXX: we should really use Portal client access here
@ -486,7 +486,7 @@ on_connect(void *data, int fd, uint32_t mask)
} }
// check SNAP permissions // check SNAP permissions
#ifdef HAVE_SNAP #ifdef HAVE_SNAP
snap_access = pw_snap_get_audio_permissions(client, client_fd, &snap_app_id); snap_access = pw_snap_get_audio_permissions(client, client->source->fd, &snap_app_id);
if ((snap_access & PW_SANDBOX_ACCESS_NOT_A_SANDBOX) == 0) { if ((snap_access & PW_SANDBOX_ACCESS_NOT_A_SANDBOX) == 0) {
pw_properties_set(client->props, PW_KEY_SNAP_ID, snap_app_id); pw_properties_set(client->props, PW_KEY_SNAP_ID, snap_app_id);
@ -503,12 +503,12 @@ on_connect(void *data, int fd, uint32_t mask)
else if (server->addr.ss_family == AF_INET || server->addr.ss_family == AF_INET6) { else if (server->addr.ss_family == AF_INET || server->addr.ss_family == AF_INET6) {
val = 1; val = 1;
if (setsockopt(client_fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val)) < 0) if (setsockopt(client->source->fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val)) < 0)
pw_log_warn("setsockopt(TCP_NODELAY) failed: %m"); pw_log_warn("setsockopt(TCP_NODELAY) failed: %m");
if (server->addr.ss_family == AF_INET) { if (server->addr.ss_family == AF_INET) {
val = IPTOS_LOWDELAY; val = IPTOS_LOWDELAY;
if (setsockopt(client_fd, IPPROTO_IP, IP_TOS, &val, sizeof(val)) < 0) if (setsockopt(client->source->fd, IPPROTO_IP, IP_TOS, &val, sizeof(val)) < 0)
pw_log_warn("setsockopt(IP_TOS) failed: %m"); pw_log_warn("setsockopt(IP_TOS) failed: %m");
} }
if (client_access == NULL) if (client_access == NULL)