[PATCH wayland] cursor: Use shm_open() instead of XDG_RUNTIME_DIR files

Pekka Paalanen ppaalanen at gmail.com
Thu Oct 19 13:16:04 UTC 2017


On Thu, 19 Oct 2017 13:12:57 +0100
Emmanuel Gil Peyrot <linkmauve at linkmauve.fr> wrote:

> On Wed, Oct 18, 2017 at 09:05:46AM -0500, Matt Hoosier wrote:
> > On Wed, Oct 18, 2017 at 4:23 AM, Quentin Glidic
> > <sardemff7+wayland at sardemff7.net> wrote:  
> > > +       fd = shm_open("/wayland-cursor-shared", O_CREAT | O_RDWR, 0);
> > > +       shm_unlink("/wayland-cursor-shared");  
> > 
> > This seems to be a departure from the anonymous behavior that
> > mkstemp() previously offered. shm_open() says that it will open an
> > existing shared-memory object if that pathname already exists. Isn't
> > there a race between one thread doing shm_open() and a different
> > thread doing shm_unlink() such that you could accidentally end up with
> > two different filedescriptors pointing at the same SHM object?  
> 
> On Linux I would recommend using memfd_create(2), which has all of the
> guarantees you want.  You still need a fallback for Linux older than
> 3.17 and for other POSIX systems; shm_open(3) is fine for that but your
> implementation is naive, you should generate a random name, fail if it
> already exists, and retry with another name in that case.

Hi,

while memfd would be cool, there is no need to require it from this
patch. We need the shm_open path in any case. The memfd path would be a
subject for another patch.


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/20171019/09e2c520/attachment.sig>


More information about the wayland-devel mailing list