fix(advanced-search): upstream polish — guard DoSearch drain, Yield in worker drain, drop dead ParseValue surface
This commit is contained in:
parent
70ca48cc6b
commit
dcedf91d9e
3 changed files with 14 additions and 8 deletions
|
|
@ -8,6 +8,7 @@ using Server.Commands;
|
|||
using Server.Commands.Generic;
|
||||
using Server.Engines.Spawners;
|
||||
using Server.Gumps;
|
||||
using Server.Logging;
|
||||
using Server.Network;
|
||||
using Server.Saves;
|
||||
|
||||
|
|
@ -28,6 +29,8 @@ public enum AdvancedSearchGumpOptions : long
|
|||
|
||||
public class AdvancedSearchGump : Gump
|
||||
{
|
||||
private static readonly ILogger _logger = LogFactory.GetLogger(typeof(AdvancedSearchGump));
|
||||
|
||||
private const int MaxEntries = 18;
|
||||
|
||||
private static int _threadId;
|
||||
|
|
@ -828,6 +831,13 @@ public class AdvancedSearchGump : Gump
|
|||
// Send the gump on the main thread
|
||||
Core.LoopContext.Post(() => Resend(from));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Never let a drain-phase failure escape unhandled on the ThreadPool
|
||||
// thread - that would terminate the process. The finally below still
|
||||
// restores autosave and releases the search guard.
|
||||
_logger.Warning(ex, "AdvancedSearch: search drain failed");
|
||||
}
|
||||
finally
|
||||
{
|
||||
AutoSave.SavesEnabled = (bool)state!;
|
||||
|
|
|
|||
|
|
@ -118,8 +118,10 @@ public class AdvancedSearchThreadWorker
|
|||
}
|
||||
else
|
||||
{
|
||||
// Queue is transiently empty but we're not paused yet; avoid a 100%-CPU busy-spin.
|
||||
Thread.SpinWait(1);
|
||||
// Queue is transiently empty but we're not paused yet; yield the core to
|
||||
// other runnable threads (e.g. the other still-filtering workers) instead
|
||||
// of busy-spinning.
|
||||
Thread.Yield();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -273,12 +273,6 @@ public static class AdvancedSearchUtilities
|
|||
return false;
|
||||
}
|
||||
|
||||
public static T ParseValue<T>(ReadOnlySpan<char> valuePart)
|
||||
{
|
||||
TryParseValue(valuePart, out T value);
|
||||
return value;
|
||||
}
|
||||
|
||||
internal static bool TryParseValue<T>(ReadOnlySpan<char> valuePart, out T value)
|
||||
{
|
||||
// Special handling for boolean and hexadecimal values
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue