Re: [PATCH xserver 1/2] shm, xwayland: prefer atomic close-on-exec without O_TMPFILE
On Fri, 2017-07-07 at 16:31 +0200, Jan Beich wrote: > Signed-off-by: Jan BeichAdded the equivalent bits to the meson build (hence the failure below) and merged: remote: E: failed to find patch for rev 1e23f03dd5fb6c981ef6d64c084f72fc6820ed71. remote: I: 0 patch(es) updated to state Accepted. To ssh://git.freedesktop.org/git/xorg/xserver 3e3b8a40f..1e23f03dd master -> master - ajax ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH xserver 1/2] shm, xwayland: prefer atomic close-on-exec without O_TMPFILE
On Fri, Jul 7, 2017 at 22:41:06 +0200, Jan Beich wrote: > Julien Cristauwrites: > > > On Fri, Jul 7, 2017 at 16:31:48 +0200, Jan Beich wrote: > >> - flags = fcntl(fd, F_GETFD); > >> +#ifndef HAVE_MKOSTEMP > >> + int flags = fcntl(fd, F_GETFD); > > > > Do we allow mixed declarations and code nowadays? > > xserver has quite a few of those already, even in Xext/shm.c e.g., > Those examples are all at the beginning of a block, so they don't count :) Anyway, I think https://cgit.freedesktop.org/xorg/xserver/tree/doc/c-extensions#n35 answers my question, so it's fine. Cheers, Julien ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH xserver 1/2] shm, xwayland: prefer atomic close-on-exec without O_TMPFILE
Julien Cristauwrites: > On Fri, Jul 7, 2017 at 16:31:48 +0200, Jan Beich wrote: >> -flags = fcntl(fd, F_GETFD); >> +#ifndef HAVE_MKOSTEMP >> +int flags = fcntl(fd, F_GETFD); > > Do we allow mixed declarations and code nowadays? xserver has quite a few of those already, even in Xext/shm.c e.g., doShmPutImage(DrawablePtr dst, GCPtr pGC, ... else { GCPtr putGC = GetScratchGC(depth, dst->pScreen); ... ProcShmPutImage(ClientPtr client) ... if (stuff->sendEvent) { xShmCompletionEvent ev = { .type = ShmCompletionCode, .drawable = stuff->drawable, .minorEvent = X_ShmPutImage, .majorEvent = ShmReqCode, .shmseg = stuff->shmseg, .offset = stuff->offset }; ... ProcPanoramiXShmCreatePixmap(ClientPtr client) ... FOR_NSCREENS(j) { ShmScrPrivateRec *screen_priv; ... ShmExtensionInit(void) ... for (i = 0; i < screenInfo.numScreens; i++) { ShmScrPrivateRec *screen_priv = ShmInitScreenPriv(screenInfo.screens[i]); ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH xserver 1/2] shm, xwayland: prefer atomic close-on-exec without O_TMPFILE
On Fri, Jul 7, 2017 at 16:31:48 +0200, Jan Beich wrote: > > Signed-off-by: Jan Beich> --- > Xext/shm.c | 9 +++-- > configure.ac| 2 +- > include/dix-config.h.in | 3 +++ > 3 files changed, 11 insertions(+), 3 deletions(-) > > diff --git a/Xext/shm.c b/Xext/shm.c > index 91ea90b14..6edeba6fb 100644 > --- a/Xext/shm.c > +++ b/Xext/shm.c > @@ -1199,7 +1199,6 @@ shm_tmpfile(void) > { > #ifdef SHMDIR > int fd; > - int flags; > chartemplate[] = SHMDIR "/shmfd-XX"; > #ifdef O_TMPFILE > fd = open(SHMDIR, O_TMPFILE|O_RDWR|O_CLOEXEC|O_EXCL, 0666); > @@ -1209,15 +1208,21 @@ shm_tmpfile(void) > } > ErrorF ("Not using O_TMPFILE\n"); > #endif > +#ifdef HAVE_MKOSTEMP > + fd = mkostemp(template, O_CLOEXEC); > +#else > fd = mkstemp(template); > +#endif > if (fd < 0) > return -1; > unlink(template); > - flags = fcntl(fd, F_GETFD); > +#ifndef HAVE_MKOSTEMP > + int flags = fcntl(fd, F_GETFD); Do we allow mixed declarations and code nowadays? Cheers, Julien ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
[PATCH xserver 1/2] shm, xwayland: prefer atomic close-on-exec without O_TMPFILE
Signed-off-by: Jan Beich--- Xext/shm.c | 9 +++-- configure.ac| 2 +- include/dix-config.h.in | 3 +++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Xext/shm.c b/Xext/shm.c index 91ea90b14..6edeba6fb 100644 --- a/Xext/shm.c +++ b/Xext/shm.c @@ -1199,7 +1199,6 @@ shm_tmpfile(void) { #ifdef SHMDIR int fd; - int flags; chartemplate[] = SHMDIR "/shmfd-XX"; #ifdef O_TMPFILE fd = open(SHMDIR, O_TMPFILE|O_RDWR|O_CLOEXEC|O_EXCL, 0666); @@ -1209,15 +1208,21 @@ shm_tmpfile(void) } ErrorF ("Not using O_TMPFILE\n"); #endif +#ifdef HAVE_MKOSTEMP + fd = mkostemp(template, O_CLOEXEC); +#else fd = mkstemp(template); +#endif if (fd < 0) return -1; unlink(template); - flags = fcntl(fd, F_GETFD); +#ifndef HAVE_MKOSTEMP + int flags = fcntl(fd, F_GETFD); if (flags != -1) { flags |= FD_CLOEXEC; (void) fcntl(fd, F_SETFD, ); } +#endif return fd; #else return -1; diff --git a/configure.ac b/configure.ac index e202770c1..a795ecf1e 100644 --- a/configure.ac +++ b/configure.ac @@ -157,7 +157,7 @@ dnl Checks for library functions. AC_CHECK_FUNCS([backtrace ffs geteuid getuid issetugid getresuid \ getdtablesize getifaddrs getpeereid getpeerucred getprogname getzoneid \ mmap posix_fallocate seteuid shmctl64 strncasecmp vasprintf vsnprintf \ - walkcontext setitimer poll epoll_create1]) + walkcontext setitimer poll epoll_create1 mkostemp]) AC_CONFIG_LIBOBJ_DIR([os]) AC_REPLACE_FUNCS([reallocarray strcasecmp strcasestr strlcat strlcpy strndup\ timingsafe_memcmp]) diff --git a/include/dix-config.h.in b/include/dix-config.h.in index ad1ab20a6..367d75c27 100644 --- a/include/dix-config.h.in +++ b/include/dix-config.h.in @@ -140,6 +140,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_LINUX_FB_H +/* Define to 1 if you have the `mkostemp' function. */ +#undef HAVE_MKOSTEMP + /* Define to 1 if you have the `mmap' function. */ #undef HAVE_MMAP ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel