mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 18:32:55 +08:00
Merge pull request #18816 from peppy/avoid-waiting-forever
Ban usage of `ManualResetEventSlim.Wait()` without a timeout value
This commit is contained in:
commit
9ed37621a7
@ -16,3 +16,4 @@ M:Realms.CollectionExtensions.SubscribeForNotifications`1(System.Linq.IQueryable
|
|||||||
M:Realms.CollectionExtensions.SubscribeForNotifications`1(System.Collections.Generic.IList{``0},Realms.NotificationCallbackDelegate{``0});Use osu.Game.Database.RealmObjectExtensions.QueryAsyncWithNotifications(IList<T>,NotificationCallbackDelegate<T>) instead.
|
M:Realms.CollectionExtensions.SubscribeForNotifications`1(System.Collections.Generic.IList{``0},Realms.NotificationCallbackDelegate{``0});Use osu.Game.Database.RealmObjectExtensions.QueryAsyncWithNotifications(IList<T>,NotificationCallbackDelegate<T>) instead.
|
||||||
M:System.Threading.Tasks.Task.Wait();Don't use Task.Wait. Use Task.WaitSafely() to ensure we avoid deadlocks.
|
M:System.Threading.Tasks.Task.Wait();Don't use Task.Wait. Use Task.WaitSafely() to ensure we avoid deadlocks.
|
||||||
P:System.Threading.Tasks.Task`1.Result;Don't use Task.Result. Use Task.GetResultSafely() to ensure we avoid deadlocks.
|
P:System.Threading.Tasks.Task`1.Result;Don't use Task.Result. Use Task.GetResultSafely() to ensure we avoid deadlocks.
|
||||||
|
M:System.Threading.ManualResetEventSlim.Wait();Specify a timeout to avoid waiting forever.
|
||||||
|
@ -76,7 +76,7 @@ namespace osu.Game.Benchmarks
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
done.Wait();
|
done.Wait(60000);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Benchmark]
|
[Benchmark]
|
||||||
@ -115,7 +115,7 @@ namespace osu.Game.Benchmarks
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
done.Wait();
|
done.Wait(60000);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Benchmark]
|
[Benchmark]
|
||||||
|
@ -79,11 +79,11 @@ namespace osu.Game.Tests.Database
|
|||||||
{
|
{
|
||||||
hasThreadedUsage.Set();
|
hasThreadedUsage.Set();
|
||||||
|
|
||||||
stopThreadedUsage.Wait();
|
stopThreadedUsage.Wait(60000);
|
||||||
});
|
});
|
||||||
}, TaskCreationOptions.LongRunning | TaskCreationOptions.HideScheduler);
|
}, TaskCreationOptions.LongRunning | TaskCreationOptions.HideScheduler);
|
||||||
|
|
||||||
hasThreadedUsage.Wait();
|
hasThreadedUsage.Wait(60000);
|
||||||
|
|
||||||
Assert.Throws<TimeoutException>(() =>
|
Assert.Throws<TimeoutException>(() =>
|
||||||
{
|
{
|
||||||
|
@ -46,7 +46,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
allowResponseCallback.Wait();
|
allowResponseCallback.Wait(10000);
|
||||||
allowResponseCallback.Reset();
|
allowResponseCallback.Reset();
|
||||||
Schedule(() => d?.Invoke("Incorrect password"));
|
Schedule(() => d?.Invoke("Incorrect password"));
|
||||||
});
|
});
|
||||||
|
@ -209,6 +209,10 @@ namespace osu.Game.Database
|
|||||||
|
|
||||||
public void SetMigrationCompletion() => migrationComplete.Set();
|
public void SetMigrationCompletion() => migrationComplete.Set();
|
||||||
|
|
||||||
public void WaitForMigrationCompletion() => migrationComplete.Wait();
|
public void WaitForMigrationCompletion()
|
||||||
|
{
|
||||||
|
if (!migrationComplete.Wait(300000))
|
||||||
|
throw new TimeoutException("Migration took too long (likely stuck).");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,9 @@ namespace osu.Game.Graphics
|
|||||||
framesWaitedEvent.Set();
|
framesWaitedEvent.Set();
|
||||||
}, 10, true);
|
}, 10, true);
|
||||||
|
|
||||||
framesWaitedEvent.Wait();
|
if (!framesWaitedEvent.Wait(1000))
|
||||||
|
throw new TimeoutException("Screenshot data did not arrive in a timely fashion");
|
||||||
|
|
||||||
waitDelegate.Cancel();
|
waitDelegate.Cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -451,7 +451,8 @@ namespace osu.Game
|
|||||||
readyToRun.Set();
|
readyToRun.Set();
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
readyToRun.Wait();
|
if (!readyToRun.Wait(30000))
|
||||||
|
throw new TimeoutException("Attempting to block for migration took too long.");
|
||||||
|
|
||||||
bool? cleanupSucceded = (Storage as OsuStorage)?.Migrate(Host.GetStorage(path));
|
bool? cleanupSucceded = (Storage as OsuStorage)?.Migrate(Host.GetStorage(path));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user