wayland/src
Kristian Høgsberg 853c24e699 client: Introduce functions to allocate and marshal proxies atomically
The server requires clients to only allocate one ID ahead of the previously
highest ID in order to keep the ID range tight.  Failure to do so will
make the server close the client connection.  However, the way we allocate
new IDs is racy.  The generated code looks like:

  new_proxy = wl_proxy_create(...);
  wl_proxy_marshal(proxy, ... new_proxy, ...);

If two threads do this at the same time, there's a chance that thread A
will allocate a proxy, then get pre-empted by thread B which then allocates
a proxy and then passes it to wl_proxy_marshal().  The ID for thread As
proxy will be one higher that the currently highest ID, but the ID for
thread Bs proxy will be two higher.  But since thread B prempted thread A
before it could send its new ID, B will send its new ID first, the server
will see the ID from thread Bs proxy first, and will reject it.

We fix this by introducing wl_proxy_marshal_constructor().  This
function is identical to wl_proxy_marshal(), except that it will
allocate a wl_proxy for NEW_ID arguments and send it, all under the
display mutex.  By introducing a new function, we maintain backwards
compatibility with older code from the generator, and make sure that
the new generated code has an explicit dependency on a new enough
libwayland-client.so.

A virtual Wayland merit badge goes to Kalle Vahlman, who tracked this
down and analyzed the issue.

Reported-by: Kalle Vahlman <kalle.vahlman@movial.com>
2013-11-15 20:49:36 -08:00
..
.gitignore Add a public header for the version number 2012-04-12 17:54:44 -04:00
connection.c Add support for server-side language bindings 2013-08-19 16:23:08 -07:00
event-loop.c server: Make wl_object and wl_resource opaque structs 2013-07-02 15:52:47 -04:00
Makefile.am client: Introduce functions to allocate and marshal proxies atomically 2013-11-15 20:49:36 -08:00
scanner.c client: Introduce functions to allocate and marshal proxies atomically 2013-11-15 20:49:36 -08:00
scanner.mk Rename source subdir from wayland to src 2011-08-12 16:25:14 -04:00
wayland-client-uninstalled.pc.in build: add uninstalled pkg-config files 2012-05-29 10:09:59 -04:00
wayland-client.c client: Introduce functions to allocate and marshal proxies atomically 2013-11-15 20:49:36 -08:00
wayland-client.h client: Introduce functions to allocate and marshal proxies atomically 2013-11-15 20:49:36 -08:00
wayland-client.pc.in Export the Wayland protocol XML file 2013-09-21 21:48:56 -07:00
wayland-egl.h wayland: Be consistent about #include-guard names 2013-10-21 14:39:06 -07:00
wayland-os.c os: wrap accept4(SOCK_CLOEXEC) 2012-04-25 09:37:42 +03:00
wayland-os.h os: wrap accept4(SOCK_CLOEXEC) 2012-04-25 09:37:42 +03:00
wayland-private.h Add support for server-side language bindings 2013-08-19 16:23:08 -07:00
wayland-scanner-uninstalled.pc.in build: Add wayland-scanner.pc. 2013-07-03 16:38:12 -04:00
wayland-scanner.pc.in build: Add wayland-scanner.pc. 2013-07-03 16:38:12 -04:00
wayland-server-uninstalled.pc.in build: add uninstalled pkg-config files 2012-05-29 10:09:59 -04:00
wayland-server.c server: Start documenting the server side API 2013-11-13 21:11:17 -08:00
wayland-server.h server: Add API to protect access to an SHM buffer 2013-11-13 16:31:28 -08:00
wayland-server.pc.in Export the Wayland protocol XML file 2013-09-21 21:48:56 -07:00
wayland-shm.c shm: Avoid file descriptor leak upon unsuccessful mmap 2013-11-15 16:21:45 -08:00
wayland-util.c Remove incorrect sanity-check from wl_map_insert_at 2013-06-05 17:45:47 -04:00
wayland-util.h utils: Document wl_container_of 2013-09-21 11:31:41 -07:00
wayland-version.h.in Add a public header for the version number 2012-04-12 17:54:44 -04:00