Commit 239ba393 authored by Derek Foreman's avatar Derek Foreman Committed by Daniel Stone

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: 's avatarDerek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone's avatarDaniel Stone <daniels@collabora.com>
parent 4485ed1f
......@@ -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)
{
......
......@@ -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;
}
......
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment