diff options
Diffstat (limited to 'mysys/my_lock.c')
-rw-r--r-- | mysys/my_lock.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/mysys/my_lock.c b/mysys/my_lock.c index 49c94ea838c..96abded4cc3 100644 --- a/mysys/my_lock.c +++ b/mysys/my_lock.c @@ -146,13 +146,13 @@ int my_lock(File fd, int locktype, my_off_t start, my_off_t length, DBUG_ENTER("my_lock"); DBUG_PRINT("my",("fd: %d Op: %d start: %ld Length: %ld MyFlags: %d", fd,locktype,(long) start,(long) length,MyFlags)); - if (my_disable_locking) + if (my_disable_locking && ! (MyFlags & MY_FORCE_LOCK)) DBUG_RETURN(0); #if defined(_WIN32) { int timeout_sec; - if (MyFlags & MY_DONT_WAIT) + if (MyFlags & MY_NO_WAIT) timeout_sec= 0; else timeout_sec= WIN_LOCK_INFINITE; @@ -170,10 +170,16 @@ int my_lock(File fd, int locktype, my_off_t start, my_off_t length, lock.l_start= (off_t) start; lock.l_len= (off_t) length; - if (MyFlags & MY_DONT_WAIT) + if (MyFlags & (MY_NO_WAIT | MY_SHORT_WAIT)) { if (fcntl(fd,F_SETLK,&lock) != -1) /* Check if we can lock */ - DBUG_RETURN(0); /* Ok, file locked */ + DBUG_RETURN(0); /* Ok, file locked */ + if (MyFlags & MY_NO_WAIT) + { + my_errno= (errno == EACCES) ? EAGAIN : errno ? errno : -1; + DBUG_RETURN(-1); + } + DBUG_PRINT("info",("Was locked, trying with alarm")); ALARM_INIT; while ((value=fcntl(fd,F_SETLKW,&lock)) && ! ALARM_TEST && |