File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -243,29 +243,30 @@ Expected<LazyMappedFileRegion> LazyMappedFileRegion::create(
243
243
sys::fs::file_t File = sys::fs::convertFDToNativeFile (FD);
244
244
245
245
struct FileLockRAII {
246
- LazyMappedFileRegion &LMFR;
246
+ std::string Path;
247
+ int FD;
247
248
bool IsLocked = false ;
248
249
249
250
enum LockKind { Shared, Exclusive };
250
251
251
- FileLockRAII (LazyMappedFileRegion &LMFR) : LMFR( LMFR) {}
252
+ FileLockRAII (LazyMappedFileRegion &LMFR) : Path( LMFR.Path), FD(* LMFR.FD ) {}
252
253
~FileLockRAII () { consumeError (unlock ()); }
253
254
254
255
Error lock (LockKind LK) {
255
256
if (IsLocked)
256
257
return createStringError (inconvertibleErrorCode (),
257
- LMFR. Path + " already locked" );
258
- if (std::error_code EC = sys::fs::lockFile (*LMFR. FD , LK == Exclusive))
259
- return createFileError (LMFR. Path , EC);
258
+ Path + " already locked" );
259
+ if (std::error_code EC = sys::fs::lockFile (FD, LK == Exclusive))
260
+ return createFileError (Path, EC);
260
261
IsLocked = true ;
261
262
return Error::success ();
262
263
}
263
264
264
265
Error unlock () {
265
266
if (IsLocked) {
266
267
IsLocked = false ;
267
- if (std::error_code EC = sys::fs::unlockFile (*LMFR. FD ))
268
- return createFileError (LMFR. Path , EC);
268
+ if (std::error_code EC = sys::fs::unlockFile (FD))
269
+ return createFileError (Path, EC);
269
270
}
270
271
return Error::success ();
271
272
}
You can’t perform that action at this time.
0 commit comments