[PATCH] Fix re-entrancy issues in wl_display_iterate().
andy.nichols at nokia.com
andy.nichols at nokia.com
Fri Apr 13 04:02:09 PDT 2012
Hi,
I ran into this same re-entrancy problem with when using qtwayland, and this patch does fix the issue.
~
Andy Nichols
________________________________________
From: wayland-devel-bounces+andy.nichols=nokia.com at lists.freedesktop.org [wayland-devel-bounces+andy.nichols=nokia.com at lists.freedesktop.org] on behalf of ext yan.wang at linux.intel.com [yan.wang at linux.intel.com]
Sent: Friday, April 13, 2012 10:08 AM
To: Hannu Lyytinen
Cc: Hannu Lyytinen; wayland-devel at lists.freedesktop.org
Subject: Re: [PATCH] Fix re-entrancy issues in wl_display_iterate().
> This fixes a possible re-entrancy issue in case of nested requests.
>
> ---
> src/connection.c | 8 +++++++-
> src/wayland-client.c | 6 ++++--
> src/wayland-private.h | 1 +
> 3 files changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/src/connection.c b/src/connection.c
> index 2795481..c5c9c77 100644
> --- a/src/connection.c
> +++ b/src/connection.c
> @@ -259,6 +259,12 @@ decode_cmsg(struct wl_buffer *buffer, struct msghdr
> *msg)
> }
>
> int
> +wl_connection_data_length(struct wl_connection *connection)
> +{
> + return connection->in.head - connection->in.tail;
> +}
> +
> +int
> wl_connection_data(struct wl_connection *connection, uint32_t mask)
> {
> struct iovec iov[2];
> @@ -335,7 +341,7 @@ wl_connection_data(struct wl_connection *connection,
> uint32_t mask)
> connection->in.head += len;
> }
>
> - return connection->in.head - connection->in.tail;
> + return wl_connection_data_length(connection);
> }
>
> int
> diff --git a/src/wayland-client.c b/src/wayland-client.c
> index 9057b4f..0bf8c81 100644
> --- a/src/wayland-client.c
> +++ b/src/wayland-client.c
> @@ -509,9 +509,11 @@ wl_display_iterate(struct wl_display *display,
> uint32_t mask)
> return;
> }
>
> - len = wl_connection_data(display->connection, mask);
> + wl_connection_data(display->connection, mask);
> +
> + for (;;) {
> + len = wl_connection_data_length(display->connection);
>
> - while (len > 0) {
> if ((size_t) len < sizeof p)
> break;
>
> diff --git a/src/wayland-private.h b/src/wayland-private.h
> index b843e89..416f4af 100644
> --- a/src/wayland-private.h
> +++ b/src/wayland-private.h
> @@ -65,6 +65,7 @@ void wl_connection_destroy(struct wl_connection
> *connection);
> void wl_connection_copy(struct wl_connection *connection, void *data,
> size_t size);
> void wl_connection_consume(struct wl_connection *connection, size_t
> size);
> int wl_connection_data(struct wl_connection *connection, uint32_t mask);
> +int wl_connection_data_length(struct wl_connection *connection);
> int wl_connection_write(struct wl_connection *connection, const void
> *data, size_t count);
> int wl_connection_queue(struct wl_connection *connection,
> const void *data, size_t count);
> --
> 1.7.1
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>
wl_display_iterate will be called in multiply threads? Normally, I think
it may be called in message loop thread.
Thanks.
Yan Wang
_______________________________________________
wayland-devel mailing list
wayland-devel at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel
More information about the wayland-devel
mailing list