2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 22:05:36 +00:00

locks: When checking for lock being ours handle mand-locks

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Pavel Emelyanov
2014-09-02 19:07:34 +04:00
parent 180005645c
commit 0a11aa1ff9

View File

@@ -127,7 +127,10 @@ static int lock_check_fd(int lfd, struct file_lock *fl)
{
int ret;
ret = flock(lfd, LOCK_EX | LOCK_NB);
if (fl->fl_ltype & LOCK_MAND)
ret = flock(lfd, LOCK_MAND | LOCK_RW);
else
ret = flock(lfd, LOCK_EX | LOCK_NB);
pr_debug(" `- %d/%d\n", ret, errno);
if (ret != 0) {
if (errno != EAGAIN) {
@@ -145,7 +148,9 @@ static int lock_check_fd(int lfd, struct file_lock *fl)
* on file pointed by fd.
*/
pr_debug(" `- downgrading lock back\n");
if (fl->fl_ltype == F_RDLCK)
if (fl->fl_ltype & LOCK_MAND)
flock(lfd, fl->fl_ltype);
else if (fl->fl_ltype == F_RDLCK)
flock(lfd, LOCK_SH);
}