mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-01 22:58:40 -04:00
connection: Just look at buffer size and remove redundant n_fds_out
Instead of maintaining a count of the fds in the buffer, just compute that from the buffer size. That way we don't get out of sync.
This commit is contained in:
parent
cab70c9e5d
commit
1c5578e87f
1 changed files with 7 additions and 5 deletions
|
|
@ -62,7 +62,6 @@ struct wl_closure {
|
||||||
struct wl_connection {
|
struct wl_connection {
|
||||||
struct wl_buffer in, out;
|
struct wl_buffer in, out;
|
||||||
struct wl_buffer fds_in, fds_out;
|
struct wl_buffer fds_in, fds_out;
|
||||||
int n_fds_out;
|
|
||||||
int fd;
|
int fd;
|
||||||
void *data;
|
void *data;
|
||||||
wl_connection_update_func_t update;
|
wl_connection_update_func_t update;
|
||||||
|
|
@ -158,6 +157,12 @@ wl_buffer_copy(struct wl_buffer *b, void *data, size_t count)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
wl_buffer_size(struct wl_buffer *b)
|
||||||
|
{
|
||||||
|
return b->head - b->tail;
|
||||||
|
}
|
||||||
|
|
||||||
struct wl_connection *
|
struct wl_connection *
|
||||||
wl_connection_create(int fd,
|
wl_connection_create(int fd,
|
||||||
wl_connection_update_func_t update,
|
wl_connection_update_func_t update,
|
||||||
|
|
@ -287,7 +292,6 @@ wl_connection_data(struct wl_connection *connection, uint32_t mask)
|
||||||
}
|
}
|
||||||
|
|
||||||
close_fds(&connection->fds_out);
|
close_fds(&connection->fds_out);
|
||||||
connection->n_fds_out = 0;
|
|
||||||
|
|
||||||
connection->out.tail += len;
|
connection->out.tail += len;
|
||||||
if (connection->out.tail == connection->out.head &&
|
if (connection->out.tail == connection->out.head &&
|
||||||
|
|
@ -397,13 +401,11 @@ wl_message_size_extra(const struct wl_message *message)
|
||||||
static int
|
static int
|
||||||
wl_connection_put_fd(struct wl_connection *connection, int32_t fd)
|
wl_connection_put_fd(struct wl_connection *connection, int32_t fd)
|
||||||
{
|
{
|
||||||
if (connection->n_fds_out + 1 > MAX_FDS_OUT) {
|
if (wl_buffer_size(&connection->fds_out) == MAX_FDS_OUT * sizeof fd)
|
||||||
if (wl_connection_data(connection, WL_CONNECTION_WRITABLE))
|
if (wl_connection_data(connection, WL_CONNECTION_WRITABLE))
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
wl_buffer_put(&connection->fds_out, &fd, sizeof fd);
|
wl_buffer_put(&connection->fds_out, &fd, sizeof fd);
|
||||||
connection->n_fds_out++;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue