JRuby flock silently converts LOCK_EX to LOCK_SH on read-only files
-------------------------------------------------------------------

                 Key: JRUBY-5627
                 URL: http://jira.codehaus.org/browse/JRUBY-5627
             Project: JRuby
          Issue Type: Bug
          Components: Core Classes/Modules
    Affects Versions: JRuby 1.6
         Environment: Solaris 10
            Reporter: Clayton O'Neill
            Priority: Minor


In JRUBY-1214 the behavior of File.flock was changed to silently convert 
LOCK_EX locks on files opened in read mode into LOCK_SH locks.  This was 
because some operating systems allow setting LOCK_EX on files opened for read 
only.  However, this is not specified in 
[POSIX|http://pubs.opengroup.org/onlinepubs/009695399/functions/fcntl.html].  
In fact, on Solaris, when trying to get an exclusive lock on a file opened only 
for read, the OS will return EBADF.  So this isn't really a MRI vs JVM issue, 
but an OS issue.  Any code that depends on this behavior in MRI is not portable.

All of that aside, this violates the principle of least surprise.  No one 
asking for an exclusive lock is going to be happy when their lock is silently 
converted to a shared lock, and this could very easily lead to silent data 
corruption.  

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to