Fix deadlock in sys: scheme

This patch fixes a deadlock in the sys: scheme that is triggered
when the iostat resource() is called in the same scope where the RwLock
protecting the scheme's handles is write-locked.
This commit is contained in:
Joshua Abraham
2020-01-25 17:39:51 -05:00
parent 57a6359333
commit 6a48ae3d8b

View File

@@ -85,9 +85,10 @@ impl Scheme for SysScheme {
for entry in self.files.iter() {
if entry.0 == &path_trimmed.as_bytes() {
let id = self.next_id.fetch_add(1, Ordering::SeqCst);
let data = entry.1()?;
self.handles.write().insert(id, Handle {
path: entry.0,
data: entry.1()?,
data: data,
mode: MODE_FILE | 0o444,
seek: 0
});