From 473a3a47a7d02694e659760008c1856f305cd82c Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Thu, 8 May 2014 15:03:10 -0500 Subject: [PATCH] server: Try to get a read lock if we can't get a write lock. --- server/fd.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/fd.c b/server/fd.c index fa8874c5b1a..7043d04caba 100644 --- a/server/fd.c +++ b/server/fd.c @@ -1175,8 +1175,12 @@ static int set_unix_lock( struct fd *fd, file_pos_t start, file_pos_t end, int t return 0; case EBADF: /* this can happen if we try to set a write lock on a read-only file */ - /* we just ignore that error */ - if (fl.l_type == F_WRLCK) return 1; + /* try to at least grab a read lock */ + if (fl.l_type == F_WRLCK) + { + type = F_RDLCK; + break; /* retry */ + } set_error( STATUS_ACCESS_DENIED ); return 0; #ifdef EOVERFLOW