Skip to content

Commit 413d814

Browse files
committed
Better notes about double locking.
1 parent d2039d4 commit 413d814

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

src/filesystem/directory.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,14 @@ where
144144
}
145145

146146
/// Call a callback function for each directory entry in a directory.
147+
///
148+
/// <div class="warning">
149+
///
150+
/// Do not attempt to call any methods on the VolumeManager or any of its
151+
/// handles from inside the callback. You will get a lock error because the
152+
/// object is already locked in order to do the iteration.
153+
///
154+
/// </div>
147155
pub fn iterate_dir<F>(&self, func: F) -> Result<(), Error<D::Error>>
148156
where
149157
F: FnMut(&DirEntry),

src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@ where
204204
DirAlreadyExists,
205205
/// The filesystem tried to gain a lock whilst already locked.
206206
///
207-
/// This is a bug in the filesystem. Please open an issue.
207+
/// This is either a bug in the filesystem, or you tried to access the
208+
/// filesystem API from inside a directory iterator (that isn't allowed).
208209
LockError,
209210
}
210211

src/volume_mgr.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,14 @@ where
377377
}
378378

379379
/// Call a callback function for each directory entry in a directory.
380+
///
381+
/// <div class="warning">
382+
///
383+
/// Do not attempt to call any methods on the VolumeManager or any of its
384+
/// handles from inside the callback. You will get a lock error because the
385+
/// object is already locked in order to do the iteration.
386+
///
387+
/// </div>
380388
pub fn iterate_dir<F>(&self, directory: RawDirectory, func: F) -> Result<(), Error<D::Error>>
381389
where
382390
F: FnMut(&DirEntry),

0 commit comments

Comments
 (0)