Skip to content

Commit 60a9a81

Browse files
authored
Fix potential deadlock in AssetServer on single-threaded modes. (#15808)
# Objective Fixes #15807 ## Solution We move the guard into this function. ## Testing N/A, This is just reverting to the old behavior before #15509.
1 parent cdd71af commit 60a9a81

File tree

1 file changed

+4
-4
lines changed
  • crates/bevy_asset/src/server

1 file changed

+4
-4
lines changed

crates/bevy_asset/src/server/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use either::Either;
3636
use futures_lite::{FutureExt, StreamExt};
3737
use info::*;
3838
use loaders::*;
39-
use parking_lot::RwLock;
39+
use parking_lot::{RwLock, RwLockWriteGuard};
4040
use std::path::{Path, PathBuf};
4141

4242
/// Loads and tracks the state of [`Asset`] values from a configured [`AssetReader`](crate::io::AssetReader). This can be used to kick off new asset loads and
@@ -383,7 +383,7 @@ impl AssetServer {
383383
);
384384

385385
if should_load {
386-
self.spawn_load_task(handle.clone().untyped(), path, &mut infos, guard);
386+
self.spawn_load_task(handle.clone().untyped(), path, infos, guard);
387387
}
388388

389389
handle
@@ -407,7 +407,7 @@ impl AssetServer {
407407
);
408408

409409
if should_load {
410-
self.spawn_load_task(handle.clone(), path, &mut infos, guard);
410+
self.spawn_load_task(handle.clone(), path, infos, guard);
411411
}
412412

413413
handle
@@ -417,7 +417,7 @@ impl AssetServer {
417417
&self,
418418
handle: UntypedHandle,
419419
path: AssetPath<'static>,
420-
infos: &mut AssetInfos,
420+
mut infos: RwLockWriteGuard<AssetInfos>,
421421
guard: G,
422422
) {
423423
// drop the lock on `AssetInfos` before spawning a task that may block on it in single-threaded

0 commit comments

Comments
 (0)