mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-10-29 05:40:16 -04:00
server: Calculate remaining data size after a closure is processed
When processing a closure, data in the connection can be consumed again if the closure itself invokes extra event dispatch. In that case the remaining data size is also altered, so the variable len should be updated after the closure is processed. Signed-off-by: Jaeyoon Jung <jaeyoon.jung@lge.com> Reviewed-by: Jonas Ådahl <jadahl@gmail.com> Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
This commit is contained in:
parent
ee9b69cfe0
commit
0a37511ecc
3 changed files with 12 additions and 2 deletions
|
|
@ -314,6 +314,12 @@ wl_connection_flush(struct wl_connection *connection)
|
|||
return connection->out.head - tail;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wl_connection_pending_input(struct wl_connection *connection)
|
||||
{
|
||||
return wl_buffer_size(&connection->in);
|
||||
}
|
||||
|
||||
int
|
||||
wl_connection_read(struct wl_connection *connection)
|
||||
{
|
||||
|
|
@ -350,7 +356,7 @@ wl_connection_read(struct wl_connection *connection)
|
|||
|
||||
connection->in.head += len;
|
||||
|
||||
return connection->in.head - connection->in.tail;
|
||||
return wl_connection_pending_input(connection);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
|||
|
|
@ -122,6 +122,9 @@ wl_connection_consume(struct wl_connection *connection, size_t size);
|
|||
int
|
||||
wl_connection_flush(struct wl_connection *connection);
|
||||
|
||||
uint32_t
|
||||
wl_connection_pending_input(struct wl_connection *connection);
|
||||
|
||||
int
|
||||
wl_connection_read(struct wl_connection *connection);
|
||||
|
||||
|
|
|
|||
|
|
@ -313,7 +313,6 @@ wl_client_connection_data(int fd, uint32_t mask, void *data)
|
|||
|
||||
closure = wl_connection_demarshal(client->connection, size,
|
||||
&client->objects, message);
|
||||
len -= size;
|
||||
|
||||
if (closure == NULL && errno == ENOMEM) {
|
||||
wl_resource_post_no_memory(resource);
|
||||
|
|
@ -346,6 +345,8 @@ wl_client_connection_data(int fd, uint32_t mask, void *data)
|
|||
|
||||
if (client->error)
|
||||
break;
|
||||
|
||||
len = wl_connection_pending_input(connection);
|
||||
}
|
||||
|
||||
if (client->error)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue