[PATCH v3] server: Calculate remaining data size after a closure is processed

Derek Foreman derekf at osg.samsung.com
Tue Jan 12 08:49:57 PST 2016


On 11/01/16 10:12 PM, Jaeyoon Jung wrote:
> 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 at lge.com>

Pushed (with Jonas and my Reviewed-by)
Thanks,
Derek

> ---
>  src/connection.c      | 8 +++++++-
>  src/wayland-private.h | 3 +++
>  src/wayland-server.c  | 3 ++-
>  3 files changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/src/connection.c b/src/connection.c
> index 6742f19..ed8f660 100644
> --- a/src/connection.c
> +++ b/src/connection.c
> @@ -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
> diff --git a/src/wayland-private.h b/src/wayland-private.h
> index 58ac952..7ea29ca 100644
> --- a/src/wayland-private.h
> +++ b/src/wayland-private.h
> @@ -121,6 +121,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);
>  
> diff --git a/src/wayland-server.c b/src/wayland-server.c
> index 55c0cf9..3f0e397 100644
> --- a/src/wayland-server.c
> +++ b/src/wayland-server.c
> @@ -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)
> 



More information about the wayland-devel mailing list