projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
mutex error handling
[fio.git]
/
mutex.c
diff --git
a/mutex.c
b/mutex.c
index bb417c2741d3c22cd41c707d3a62bc34e0238de1..6ec5d573e8a30145f9c53801f560c7edc329acc7 100644
(file)
--- a/
mutex.c
+++ b/
mutex.c
@@
-16,8
+16,8
@@
void fio_sem_remove(struct fio_sem *sem)
struct fio_sem *fio_sem_init(int value)
{
struct fio_sem *fio_sem_init(int value)
{
+ struct fio_sem *sem = NULL;
pthread_mutexattr_t attr;
pthread_mutexattr_t attr;
- struct fio_sem *sem;
char sem_name[32];
int fd;
char sem_name[32];
int fd;
@@
-30,7
+30,7
@@
struct fio_sem *fio_sem_init(int value)
if (ftruncate(fd, sizeof(struct fio_sem)) < 0) {
perror("ftruncate sem");
if (ftruncate(fd, sizeof(struct fio_sem)) < 0) {
perror("ftruncate sem");
-
return NULL
;
+
goto err
;
}
sem = mmap(NULL, sizeof(struct fio_sem), PROT_READ | PROT_WRITE,
}
sem = mmap(NULL, sizeof(struct fio_sem), PROT_READ | PROT_WRITE,
@@
-38,8
+38,8
@@
struct fio_sem *fio_sem_init(int value)
if (sem == MAP_FAILED) {
perror("mmap sem");
close(fd);
if (sem == MAP_FAILED) {
perror("mmap sem");
close(fd);
-
unlink(sem_name)
;
-
return NULL
;
+
sem = NULL
;
+
goto err
;
}
close(fd);
}
close(fd);
@@
-61,7
+61,8
@@
struct fio_sem *fio_sem_init(int value)
return sem;
err:
return sem;
err:
- munmap(sem, sizeof(*sem));
+ if (sem)
+ munmap(sem, sizeof(*sem));
unlink(sem_name);
return NULL;
}
unlink(sem_name);
return NULL;
}