~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lock.py

  • Committer: Martin Pool
  • Date: 2005-07-07 10:22:02 UTC
  • Revision ID: mbp@sourcefrog.net-20050707102201-2d2a13a25098b101
- rearrange and clear up merged weave

Show diffs side-by-side

added added

removed removed

Lines of Context:
84
84
        f = None
85
85
 
86
86
        def unlock(self):
87
 
            fcntl.lockf(self.f, fcntl.LOCK_UN)
 
87
            fcntl.flock(self.f, fcntl.LOCK_UN)
88
88
            self.f.close()
89
89
            del self.f 
90
90
 
92
92
    class _fcntl_WriteLock(_fcntl_FileLock):
93
93
        def __init__(self, filename):
94
94
            try:
95
 
                fcntl.lockf(self._open(filename, 'wb'), fcntl.LOCK_EX)
 
95
                fcntl.flock(self._open(filename, 'wb'), fcntl.LOCK_EX)
96
96
            except Exception, e:
97
97
                raise LockError(e)
98
98
 
100
100
    class _fcntl_ReadLock(_fcntl_FileLock):
101
101
        def __init__(self, filename):
102
102
            try:
103
 
                fcntl.lockf(self._open(filename, 'rb'), fcntl.LOCK_SH)
 
103
                fcntl.flock(self._open(filename, 'rb'), fcntl.LOCK_SH)
104
104
            except Exception, e:
105
105
                raise LockError(e)
106
106
 
168
168
                LOCK_NB = 4
169
169
                def unlock(self):
170
170
                    _msvc_unlock(self.f)
171
 
                    self.f.close()
172
 
                    self.f = None
173
171
 
174
172
 
175
173
            class _msvc_ReadLock(_msvc_FileLock):
200
198
                        fpos = os.lseek(fn, 0,0)
201
199
                        os.lseek(fn, 0,0)
202
200
 
203
 
                    if flags & _msvc_FileLock.LOCK_SH:
204
 
                        if flags & _msvc_FileLock.LOCK_NB:
 
201
                    if flags & self.LOCK_SH:
 
202
                        if flags & self.LOCK_NB:
205
203
                            lock_mode = msvcrt.LK_NBLCK
206
204
                        else:
207
205
                            lock_mode = msvcrt.LK_LOCK
208
 
                    elif flags & _msvc_FileLock.LOCK_EX:
209
 
                        if flags & _msvc_FileLock.LOCK_NB:
 
206
                    elif flags & self.LOCK_EX:
 
207
                        if flags & self.LOCK_NB:
210
208
                            lock_mode = msvcrt.LK_NBRLCK
211
209
                        else:
212
210
                            lock_mode = msvcrt.LK_RLCK