diff options
| author | Derek Foreman <derek.foreman@collabora.com> | 2021-07-21 16:32:36 -0500 |
|---|---|---|
| committer | Daniel Stone <daniels@collabora.com> | 2021-08-07 11:53:23 +0000 |
| commit | 0e0274af0c9f60d2759713df136f4294054c9096 (patch) | |
| tree | e5eb0b0f359abc61f8e7d8f9d429f5fa995530a8 /src | |
| parent | client: Add new proxy marshalling functions with flags (diff) | |
| download | wayland-0e0274af0c9f60d2759713df136f4294054c9096.tar wayland-0e0274af0c9f60d2759713df136f4294054c9096.tar.gz wayland-0e0274af0c9f60d2759713df136f4294054c9096.tar.bz2 wayland-0e0274af0c9f60d2759713df136f4294054c9096.tar.lz wayland-0e0274af0c9f60d2759713df136f4294054c9096.tar.xz wayland-0e0274af0c9f60d2759713df136f4294054c9096.tar.zst wayland-0e0274af0c9f60d2759713df136f4294054c9096.zip | |
scanner: Use the new atomic marshal/destroy function
Use the new flagged marshal+destroy function in generated code.
It's intended as a replacement for all existing wl_proxy_marshal_*
functions, so I've used it to replace them all. This results in a large
update to the scanner test files as well.
We now pass the new WL_MARSHAL_FLAG_DESTROY flag when appropriate, so
the race condition in #86 caused by releasing the display mutex between
marshalling the proxy and destroying the proxy is now gone.
Fixes #86
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/scanner.c | 63 |
1 files changed, 30 insertions, 33 deletions
diff --git a/src/scanner.c b/src/scanner.c index 64df6e8..6a95603 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -1238,38 +1238,40 @@ emit_stubs(struct wl_list *message_list, struct interface *interface) printf(")\n" "{\n"); - if (ret && ret->interface_name == NULL) { - /* an arg has type ="new_id" but interface is not - * provided, such as in wl_registry.bind */ - printf("\tstruct wl_proxy *%s;\n\n" - "\t%s = wl_proxy_marshal_constructor_versioned(" - "(struct wl_proxy *) %s,\n" - "\t\t\t %s_%s, interface, version", - ret->name, ret->name, - interface->name, - interface->uppercase_name, - m->uppercase_name); - } else if (ret) { - /* Normal factory case, an arg has type="new_id" and - * an interface is provided */ - printf("\tstruct wl_proxy *%s;\n\n" - "\t%s = wl_proxy_marshal_constructor(" - "(struct wl_proxy *) %s,\n" - "\t\t\t %s_%s, &%s_interface", - ret->name, ret->name, - interface->name, - interface->uppercase_name, - m->uppercase_name, - ret->interface_name); + printf("\t"); + if (ret) { + printf("struct wl_proxy *%s;\n\n" + "\t%s = ", ret->name, ret->name); + } + printf("wl_proxy_marshal_flags(" + "(struct wl_proxy *) %s,\n" + "\t\t\t %s_%s", + interface->name, + interface->uppercase_name, + m->uppercase_name); + + if (ret) { + if (ret->interface_name) { + /* Normal factory case, an arg has type="new_id" and + * an interface is provided */ + printf(", &%s_interface", ret->interface_name); + } else { + /* an arg has type ="new_id" but interface is not + * provided, such as in wl_registry.bind */ + printf(", interface"); + } } else { /* No args have type="new_id" */ - printf("\twl_proxy_marshal((struct wl_proxy *) %s,\n" - "\t\t\t %s_%s", - interface->name, - interface->uppercase_name, - m->uppercase_name); + printf(", NULL"); } + if (ret && ret->interface_name == NULL) + printf(", version"); + else + printf(", wl_proxy_get_version((struct wl_proxy *) %s)", + interface->name); + printf(", %s", m->destructor ? "WL_MARSHAL_FLAG_DESTROY" : "0"); + wl_list_for_each(a, &m->arg_list, link) { if (a->type == NEW_ID) { if (a->interface_name == NULL) @@ -1281,11 +1283,6 @@ emit_stubs(struct wl_list *message_list, struct interface *interface) } printf(");\n"); - if (m->destructor) - printf("\n\twl_proxy_destroy(" - "(struct wl_proxy *) %s);\n", - interface->name); - if (ret && ret->interface_name == NULL) printf("\n\treturn (void *) %s;\n", ret->name); else if (ret) |
