<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Aug 21, 2014 at 4:00 AM, Pekka Paalanen <span dir="ltr"><<a href="mailto:ppaalanen@gmail.com" target="_blank">ppaalanen@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Thu, 7 Aug 2014 09:55:49 -0400<br>
<div class="">"Jasper St. Pierre" <<a href="mailto:jstpierre@mecheye.net">jstpierre@mecheye.net</a>> wrote:<br>
<br>
</div><div><div class="h5">> The idea here was that once upon a time, clients could rebind wl_display<br>
> to a higher version, so we offered the ability to rebind it<br>
> here. However, this is particularly broken. The existing bind<br>
> implementation actually still hardcodes version numbers, and it leaks<br>
> previous resources, overwriting the existing one.<br>
><br>
> The newly bound resource *also* won't have any listeners attached by the<br>
> client, meaning that the error and delete_id events won't get delivered<br>
> correctly. Unless the client poked into libwayland internals, it also<br>
> can't possibly set up these handlers correctly either, so the client<br>
> will sustain errors and leak all deleted globals.<br>
><br>
> Since this never worked correctly in the first place, we can feel safe<br>
> removing it.<br>
> ---<br>
> src/wayland-server.c | 28 ++++++++--------------------<br>
> 1 file changed, 8 insertions(+), 20 deletions(-)<br>
><br>
> diff --git a/src/wayland-server.c b/src/wayland-server.c<br>
> index 3c162d4..dc3f502 100644<br>
> --- a/src/wayland-server.c<br>
> +++ b/src/wayland-server.c<br>
> @@ -380,9 +380,8 @@ wl_client_get_display(struct wl_client *client)<br>
> return client->display;<br>
> }<br>
><br>
> -static void<br>
> -bind_display(struct wl_client *client,<br>
> - void *data, uint32_t version, uint32_t id);<br>
> +static int<br>
> +bind_display(struct wl_client *client, struct wl_display *display);<br>
><br>
> /** Create a client for the given file descriptor<br>
> *<br>
> @@ -440,9 +439,7 @@ wl_client_create(struct wl_display *display, int fd)<br>
> goto err_map;<br>
><br>
> wl_signal_init(&client->destroy_signal);<br>
> - bind_display(client, display, 1, 1);<br>
> -<br>
> - if (!client->display_resource)<br>
> + if (bind_display(client, display) < 0)<br>
> goto err_map;<br>
><br>
> wl_list_insert(display->client_list.prev, &client->link);<br>
> @@ -772,22 +769,20 @@ destroy_client_display_resource(struct wl_resource *resource)<br>
> resource->client->display_resource = NULL;<br>
> }<br>
><br>
> -static void<br>
> -bind_display(struct wl_client *client,<br>
> - void *data, uint32_t version, uint32_t id)<br>
> +static int<br>
> +bind_display(struct wl_client *client, struct wl_display *display)<br>
> {<br>
> - struct wl_display *display = data;<br>
> -<br>
> client->display_resource =<br>
> - wl_resource_create(client, &wl_display_interface, 1, id);<br>
> + wl_resource_create(client, &wl_display_interface, 1, 1);<br>
> if (client->display_resource == NULL) {<br>
> wl_client_post_no_memory(client);<br>
> - return;<br>
> + return -1;<br>
> }<br>
><br>
> wl_resource_set_implementation(client->display_resource,<br>
> &display_interface, display,<br>
> destroy_client_display_resource);<br>
> + return 0;<br>
> }<br>
><br>
> /** Create Wayland display object.<br>
> @@ -831,13 +826,6 @@ wl_display_create(void)<br>
><br>
> wl_array_init(&display->additional_shm_formats);<br>
><br>
> - if (!wl_global_create(display, &wl_display_interface, 1,<br>
> - display, bind_display)) {<br>
> - wl_event_loop_destroy(display->loop);<br>
> - free(display);<br>
> - return NULL;<br>
> - }<br>
> -<br>
> return display;<br>
> }<br>
><br>
<br>
</div></div>I asked krh about this in irc, and he eventually agreed that exposing<br>
wl_display as a global is not so useful.<br>
<br>
I reviewed the patch, and the alleged problems the current code has,<br>
and I agree they are real.<br>
<br>
If we ever end up needing wl_display as a global, we can easily add it<br>
back. Since the implementation was indeed broken, no client should ever<br>
try to bind to wl_display global with version 1.<br>
<br>
Therefore, pushed with ack from Jason and R-b from me.<br>
<br>
In fact, I think this warrants this patch as a condidate for the stable<br>
branch.<br></blockquote><div><br></div><div>Yeah, it probably counts as a bug-fix. It does change behaviour though, so I'm not sure I really want to call it a stable thing. Unless, of course, re-binding wl_display could cause a crash; in which case, push it to 1.5<br>
</div><div>--Jason<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
Thanks,<br>
pq<br>
</blockquote></div><br></div></div>