mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-04 13:29:51 -05:00
connection: close pending outgoing fds on shutdown
When destroying a wl_connection object, there might still be data in the queue. We would leak open file-descriptors so we must close them. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
parent
c13a65fd20
commit
cda89f3a42
1 changed files with 18 additions and 17 deletions
|
|
@ -167,9 +167,27 @@ wl_connection_create(int fd)
|
|||
return connection;
|
||||
}
|
||||
|
||||
static void
|
||||
close_fds(struct wl_buffer *buffer)
|
||||
{
|
||||
int fds[MAX_FDS_OUT], i, count;
|
||||
size_t size;
|
||||
|
||||
size = buffer->head - buffer->tail;
|
||||
if (size == 0)
|
||||
return;
|
||||
|
||||
wl_buffer_copy(buffer, fds, size);
|
||||
count = size / sizeof fds[0];
|
||||
for (i = 0; i < count; i++)
|
||||
close(fds[i]);
|
||||
buffer->tail += size;
|
||||
}
|
||||
|
||||
void
|
||||
wl_connection_destroy(struct wl_connection *connection)
|
||||
{
|
||||
close_fds(&connection->fds_out);
|
||||
close(connection->fd);
|
||||
free(connection);
|
||||
}
|
||||
|
|
@ -205,23 +223,6 @@ build_cmsg(struct wl_buffer *buffer, char *data, int *clen)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
close_fds(struct wl_buffer *buffer)
|
||||
{
|
||||
int fds[MAX_FDS_OUT], i, count;
|
||||
size_t size;
|
||||
|
||||
size = buffer->head - buffer->tail;
|
||||
if (size == 0)
|
||||
return;
|
||||
|
||||
wl_buffer_copy(buffer, fds, size);
|
||||
count = size / sizeof fds[0];
|
||||
for (i = 0; i < count; i++)
|
||||
close(fds[i]);
|
||||
buffer->tail += size;
|
||||
}
|
||||
|
||||
static void
|
||||
decode_cmsg(struct wl_buffer *buffer, struct msghdr *msg)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue