src/t_mtab: Add error check for unlock_mtab()

When unlink() fails, that is, when the lock file is not deleted
successfully, variable we_created_lockfile is still set to 0.

On the next iteration, the 3 processes will not be able to
successfully create the lock file.

Signed-off-by: Cui Yue <cuiyue-fnst@cn.fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
This commit is contained in:
Cui Yue
2019-02-12 19:12:30 +08:00
committed by Eryu Guan
parent a70fb7335c
commit 0177f3c458
+8 -2
View File
@@ -184,9 +184,15 @@ lock_mtab (void) {
/* Remove lock file. */ /* Remove lock file. */
void void
unlock_mtab (void) { unlock_mtab (void) {
int ret;
if (we_created_lockfile) { if (we_created_lockfile) {
unlink (mounted_lock); ret = unlink (mounted_lock);
we_created_lockfile = 0; if (ret) {
fprintf(stderr, "Cannot remove lock file: %s\n", strerror(errno));
exit(1);
} else {
we_created_lockfile = 0;
}
} }
} }