When `wl_resource_destructor` gets called after `wl_proxy_destroy` called on the client sides.

Pekka Paalanen ppaalanen at gmail.com
Thu Oct 10 11:44:37 UTC 2019


On Wed, 9 Oct 2019 16:52:33 -0400
Sichem Zhou <sichem.zh at gmail.com> wrote:

> Hi wayland devs,
> 
> I have a question regarding the life span of wayland objects. I know
> wayland is a asynchronous API, but is there a way to know when the
> wl_resource gets destroyed once `wl_proxy_destroy` in the clients?

Hi,

if the protocol interface defines a destructor request, the server will
receive that request and in response call wl_resource_destroy(). This
always happens manually in a server, except in the case of client
disconnecting.

If the protocol does not define a destructor request, or it does but it
is not named "destroy" and the client calls wl_..._destroy(), or a
client calls wl_proxy_destroy() directly, then the server cannot know
it should destroy the wl_resource. These issues are bugs in the
protocol design or in the client implementation.

>  The use case is that clients creates some wl_objects on server signal and
> the client can destroy the objects at some point. When sever want to
> trigger such signal again, it can check whether such objects already exist
> for the client(once wl_resource_destroy, server knows clients no longer has
> it). If server still thinks the wl_object exists and it was actually
> destroyed by client. It would have server to skip.

Be careful with such a design, because there is an inherent race. It is
possible that the server skips sending the signal at the same time the
client destroys the object, leading to a case where the object is
missing when it was expected to exist or appear.

> If clients dont tell to the server on it's destruction of objects, when
> would server know to free the wl_resources though?

On client disconnect. There is no other way if the protocol interface
does not define a destructor request.


Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20191010/8ce48916/attachment.sig>


More information about the wayland-devel mailing list