mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
locking: avoid descriptor leak for nonblocking mode
When file-locking mode failed on locking, such description was leaked (typically not an issue since command usually exists afterwards). So shirt close() at the end of function and use it in all error paths. Also make sure, when interrrupt is detected, it's really not holding lock and returns 0.
This commit is contained in:
parent
043ff47b05
commit
5de9444202
@ -1,5 +1,6 @@
|
||||
Version 2.02.174 -
|
||||
=================================
|
||||
Fix leaking of file descriptor for non-blocking filebased locking.
|
||||
Fix check for 2nd mda at end of disk fits if using pvcreate --restorefile.
|
||||
Use maximum metadataarea size that fits with pvcreate --restorefile.
|
||||
Always clear cached bootloaderarea when wiping label e.g. in pvcreate.
|
||||
|
@ -116,17 +116,16 @@ static int _do_flock(const char *file, int *fd, int operation, uint32_t nonblock
|
||||
old_errno = errno;
|
||||
if (!nonblock) {
|
||||
sigint_restore();
|
||||
if (sigint_caught())
|
||||
if (sigint_caught()) {
|
||||
log_error("Giving up waiting for lock.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (r) {
|
||||
errno = old_errno;
|
||||
log_sys_error("flock", file);
|
||||
if (close(*fd))
|
||||
log_sys_debug("close", file);
|
||||
*fd = -1;
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!stat(file, &buf1) && !fstat(*fd, &buf2) &&
|
||||
@ -134,6 +133,10 @@ static int _do_flock(const char *file, int *fd, int operation, uint32_t nonblock
|
||||
return 1;
|
||||
} while (!nonblock);
|
||||
|
||||
if (close(*fd))
|
||||
log_sys_debug("close", file);
|
||||
*fd = -1;
|
||||
|
||||
return_0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user