From b9c3a0e30f6a939b1e1e3142cb507dfe7993b683 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 11 Mar 2017 08:32:13 -0500 Subject: [PATCH] Fix deadlocks in hacker commands. --- ShiftOS.WinForms/HackerCommands.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ShiftOS.WinForms/HackerCommands.cs b/ShiftOS.WinForms/HackerCommands.cs index d9504d3..59d0f4e 100644 --- a/ShiftOS.WinForms/HackerCommands.cs +++ b/ShiftOS.WinForms/HackerCommands.cs @@ -378,6 +378,8 @@ namespace ShiftOS.WinForms { Console.WriteLine("--operation took too long - failed."); ServerManager.SendMessage("mud_save_allow_dead", JsonConvert.SerializeObject(sve)); + ServerManager.MessageReceived -= msgReceived; + TerminalBackend.PrefixEnabled = true; return; } sw.Stop(); @@ -395,6 +397,7 @@ namespace ShiftOS.WinForms ServerManager.MessageReceived -= msgReceived; TerminalBackend.PrintPrompt(); } + TerminalBackend.PrefixEnabled = true; }; Console.WriteLine("--beginning brute-force attack on " + usr + "@" + sys + "..."); @@ -405,6 +408,7 @@ namespace ShiftOS.WinForms user = usr, sysname = sys })); + TerminalBackend.PrefixEnabled = false; Thread.Sleep(500); return true; } @@ -446,7 +450,7 @@ namespace ShiftOS.WinForms received = true; ServerManager.MessageReceived -= msgReceived; TerminalBackend.PrintPrompt(); - + } else if (msg.Name == "user_data_not_found") { @@ -455,6 +459,7 @@ namespace ShiftOS.WinForms ServerManager.MessageReceived -= msgReceived; TerminalBackend.PrintPrompt(); } + TerminalBackend.PrefixEnabled = true; }; Console.WriteLine("--contacting multi-user domain..."); @@ -466,6 +471,7 @@ namespace ShiftOS.WinForms sysname = sys })); Thread.Sleep(500); + TerminalBackend.PrefixEnabled = false; return true; } @@ -504,6 +510,7 @@ namespace ShiftOS.WinForms { Console.WriteLine("--can't steal this many codepoints from user."); ServerManager.SendMessage("mud_save_allow_dead", JsonConvert.SerializeObject(sve)); + TerminalBackend.PrefixEnabled = true; return; } @@ -527,6 +534,7 @@ namespace ShiftOS.WinForms ServerManager.MessageReceived -= msgReceived; TerminalBackend.PrintPrompt(); } + TerminalBackend.PrefixEnabled = true; }; Console.WriteLine("--contacting multi-user domain..."); @@ -539,7 +547,7 @@ namespace ShiftOS.WinForms sysname = sys })); Thread.Sleep(500); - + TerminalBackend.PrefixEnabled = false; return true; } @@ -580,6 +588,7 @@ namespace ShiftOS.WinForms ServerManager.MessageReceived -= msgReceived; } TerminalBackend.PrintPrompt(); + TerminalBackend.PrefixEnabled = true; }; Console.WriteLine("--contacting multi-user domain..."); @@ -592,7 +601,7 @@ namespace ShiftOS.WinForms sysname = sys })); Thread.Sleep(500); - + TerminalBackend.PrefixEnabled = false; return true; }