diff options
| author | Derek Foreman <derekf@osg.samsung.com> | 2017-12-06 11:22:23 -0600 |
|---|---|---|
| committer | Daniel Stone <daniels@collabora.com> | 2018-01-09 15:20:00 +0000 |
| commit | 239ba39331420f953de35c337ae57db35573f9cb (patch) | |
| tree | 3c8efe369f2a4aa7151b8fe2f22d206a9eeeff29 /src | |
| parent | client: Replace the singleton zombie with bespoke zombies (diff) | |
| download | wayland-239ba39331420f953de35c337ae57db35573f9cb.tar wayland-239ba39331420f953de35c337ae57db35573f9cb.tar.gz wayland-239ba39331420f953de35c337ae57db35573f9cb.tar.bz2 wayland-239ba39331420f953de35c337ae57db35573f9cb.tar.lz wayland-239ba39331420f953de35c337ae57db35573f9cb.tar.xz wayland-239ba39331420f953de35c337ae57db35573f9cb.tar.zst wayland-239ba39331420f953de35c337ae57db35573f9cb.zip | |
client: Consume file descriptors destined for zombie proxies
We need to close file descriptors sent to zombie proxies to avoid leaking
them, and perhaps more importantly, to prevent them from being dispatched
in events on other objects (since they would previously be left in the
buffer and potentially fed to following events destined for live proxies)
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/connection.c | 6 | ||||
| -rw-r--r-- | src/wayland-client.c | 8 | ||||
| -rw-r--r-- | src/wayland-private.h | 3 |
3 files changed, 17 insertions, 0 deletions
diff --git a/src/connection.c b/src/connection.c index 426be57..6f83bab 100644 --- a/src/connection.c +++ b/src/connection.c @@ -192,6 +192,12 @@ close_fds(struct wl_buffer *buffer, int max) buffer->tail += size; } +void +wl_connection_close_fds_in(struct wl_connection *connection, int max) +{ + close_fds(&connection->fds_in, max); +} + int wl_connection_destroy(struct wl_connection *connection) { diff --git a/src/wayland-client.c b/src/wayland-client.c index 62d4f22..c1369b8 100644 --- a/src/wayland-client.c +++ b/src/wayland-client.c @@ -1353,8 +1353,16 @@ queue_event(struct wl_display *display, int len) if (len < size) return 0; + /* If our proxy is gone or a zombie, just eat the event (and any FDs, + * if applicable). */ proxy = wl_map_lookup(&display->objects, id); if (!proxy || wl_object_is_zombie(&display->objects, id)) { + struct wl_zombie *zombie = wl_map_lookup(&display->objects, id); + + if (zombie) + wl_connection_close_fds_in(display->connection, + zombie->fd_count[opcode]); + wl_connection_consume(display->connection, size); return size; } diff --git a/src/wayland-private.h b/src/wayland-private.h index 8e94864..12b9032 100644 --- a/src/wayland-private.h +++ b/src/wayland-private.h @@ -253,4 +253,7 @@ wl_priv_signal_get(struct wl_priv_signal *signal, wl_notify_func_t notify); void wl_priv_signal_emit(struct wl_priv_signal *signal, void *data); +void +wl_connection_close_fds_in(struct wl_connection *connection, int max); + #endif |
