~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lock.py

  • Committer: Martin Pool
  • Date: 2009-09-14 01:48:28 UTC
  • mfrom: (4685 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4688.
  • Revision ID: mbp@sourcefrog.net-20090914014828-ydr9rlkdfq2sv57z
Merge news

Show diffs side-by-side

added added

removed removed

Lines of Context:
190
190
            if self.filename in _fcntl_WriteLock._open_locks:
191
191
                self._clear_f()
192
192
                raise errors.LockContention(self.filename)
 
193
            if self.filename in _fcntl_ReadLock._open_locks:
 
194
                if 'strict_locks' in debug.debug_flags:
 
195
                    self._clear_f()
 
196
                    raise errors.LockContention(self.filename)
 
197
                else:
 
198
                    trace.mutter('Write lock taken w/ an open read lock on: %s'
 
199
                                 % (self.filename,))
193
200
 
194
201
            self._open(self.filename, 'rb+')
195
202
            # reserve a slot for this lock - even if the lockf call fails,
220
227
        def __init__(self, filename):
221
228
            super(_fcntl_ReadLock, self).__init__()
222
229
            self.filename = osutils.realpath(filename)
 
230
            if self.filename in _fcntl_WriteLock._open_locks:
 
231
                if 'strict_locks' in debug.debug_flags:
 
232
                    # We raise before calling _open so we don't need to
 
233
                    # _clear_f
 
234
                    raise errors.LockContention(self.filename)
 
235
                else:
 
236
                    trace.mutter('Read lock taken w/ an open write lock on: %s'
 
237
                                 % (self.filename,))
223
238
            _fcntl_ReadLock._open_locks.setdefault(self.filename, 0)
224
239
            _fcntl_ReadLock._open_locks[self.filename] += 1
225
240
            self._open(filename, 'rb')
418
433
            DWORD,                 # dwFlagsAndAttributes
419
434
            HANDLE                 # hTemplateFile
420
435
        )((_function_name, ctypes.windll.kernel32))
421
 
    
 
436
 
422
437
    INVALID_HANDLE_VALUE = -1
423
 
    
 
438
 
424
439
    GENERIC_READ = 0x80000000
425
440
    GENERIC_WRITE = 0x40000000
426
441
    FILE_SHARE_READ = 1
427
442
    OPEN_ALWAYS = 4
428
443
    FILE_ATTRIBUTE_NORMAL = 128
429
 
    
 
444
 
430
445
    ERROR_ACCESS_DENIED = 5
431
446
    ERROR_SHARING_VIOLATION = 32
432
447