avoid using mktemp since it triggers warnings
Bump rev.
This commit is contained in:
parent
e9eb06fc0a
commit
d04fbb52b7
2 changed files with 29 additions and 11 deletions
|
@ -1,7 +1,7 @@
|
|||
# $NetBSD: Makefile,v 1.4 2015/09/24 23:57:27 tnn Exp $
|
||||
# $NetBSD: Makefile,v 1.5 2016/05/04 02:43:31 tnn Exp $
|
||||
|
||||
DISTNAME= libxshmfence-1.2
|
||||
PKGREVISION= 2
|
||||
PKGREVISION= 3
|
||||
CATEGORIES= x11
|
||||
MASTER_SITES= http://xorg.freedesktop.org/archive/individual/lib/
|
||||
EXTRACT_SUFX= .tar.bz2
|
||||
|
|
|
@ -25,13 +25,16 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "xshmfenceint.h"
|
||||
|
||||
static sem_t *mksemtemp(char *, const char *);
|
||||
|
||||
#define LOCK() do {} while (sem_wait(f->lock) != 0)
|
||||
#define UNLOCK() do { sem_post(f->lock); } while (0)
|
||||
#define COND_WAIT() do {} while (sem_wait(f->cond) != 0)
|
||||
|
@ -155,16 +158,12 @@ xshmfence_init(int fd)
|
|||
__sync_fetch_and_and(&f.triggered, 0);
|
||||
__sync_fetch_and_and(&f.waiting, 0);
|
||||
|
||||
strlcpy(f.lockname, "/xshmfl-XXXX", sizeof(f.lockname));
|
||||
mktemp(f.lockname);
|
||||
lock = sem_open(f.lockname, O_CREAT|O_EXCL, 0600, 1);
|
||||
lock = mksemtemp(f.lockname, "/xshmfl-%i");
|
||||
if (lock == SEM_FAILED) {
|
||||
err(EXIT_FAILURE, "xshmfence_init: sem_open");
|
||||
}
|
||||
|
||||
strlcpy(f.condname, "/xshmfc-XXXX", sizeof(f.condname));
|
||||
mktemp(f.condname);
|
||||
cond = sem_open(f.condname, O_CREAT|O_EXCL, 0600, 0);
|
||||
|
||||
cond = mksemtemp(f.condname, "/xshmfl-%i");
|
||||
if (cond == SEM_FAILED) {
|
||||
err(EXIT_FAILURE, "xshmfence_init: sem_open");
|
||||
}
|
||||
|
@ -221,3 +220,22 @@ xshmfence_close_semaphore(struct xshmfence *f)
|
|||
sem_unlink(f->condname);
|
||||
}
|
||||
}
|
||||
|
||||
static sem_t *
|
||||
mksemtemp(char *name, const char *template)
|
||||
{
|
||||
sem_t *ret;
|
||||
pid_t p;
|
||||
p = getpid();
|
||||
for(;;) {
|
||||
sprintf(name, template, p);
|
||||
ret = sem_open(name, O_CREAT|O_EXCL, 0600, 1);
|
||||
if (ret == SEM_FAILED) {
|
||||
if (errno == EEXIST) {
|
||||
p++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue