Fix for concurrent child processes while using pipes for IPC.
This commit is contained in:
@@ -107,10 +107,11 @@ namespace OpenRA.Launcher
|
||||
string[] args = e.Argument as string[];
|
||||
string url = args[0];
|
||||
string dest = args[1];
|
||||
var p = UtilityProgram.Call("--download-url", url, dest);
|
||||
string pipename = UtilityProgram.GetPipeName();
|
||||
var p = UtilityProgram.Call("--download-url", pipename, url, dest);
|
||||
Regex r = new Regex(@"(\d{1,3})% (\d+)/(\d+) bytes");
|
||||
|
||||
NamedPipeClientStream pipe = new NamedPipeClientStream(".", "OpenRA.Utility", PipeDirection.In);
|
||||
NamedPipeClientStream pipe = new NamedPipeClientStream(".", pipename, PipeDirection.In);
|
||||
pipe.Connect();
|
||||
|
||||
using (var response = new StreamReader(pipe))
|
||||
@@ -176,8 +177,9 @@ namespace OpenRA.Launcher
|
||||
string zipFile = args[0];
|
||||
string destPath = args[1];
|
||||
|
||||
var p = UtilityProgram.CallWithAdmin("--extract-zip", zipFile, destPath);
|
||||
var pipe = new NamedPipeClientStream(".", "OpenRA.Utility", PipeDirection.In);
|
||||
string pipename = UtilityProgram.GetPipeName();
|
||||
var p = UtilityProgram.CallWithAdmin("--extract-zip", pipename, zipFile, destPath);
|
||||
var pipe = new NamedPipeClientStream(".", pipename, PipeDirection.In);
|
||||
|
||||
pipe.Connect();
|
||||
|
||||
|
||||
1
OpenRA.Launcher/Launcher.Designer.cs
generated
1
OpenRA.Launcher/Launcher.Designer.cs
generated
@@ -150,6 +150,7 @@
|
||||
this.Name = "Launcher";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "OpenRA Launcher";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.formClosing);
|
||||
this.splitContainer1.Panel1.ResumeLayout(false);
|
||||
this.splitContainer1.Panel2.ResumeLayout(false);
|
||||
this.splitContainer1.ResumeLayout(false);
|
||||
|
||||
@@ -112,8 +112,9 @@ namespace OpenRA.Launcher
|
||||
private void InstallMod(object sender, EventArgs e)
|
||||
{
|
||||
if (installModDialog.ShowDialog() != DialogResult.OK) return;
|
||||
var p = UtilityProgram.CallWithAdmin("--extract-zip", installModDialog.FileName, "");
|
||||
var pipe = new NamedPipeClientStream(".", "OpenRA.Utility", PipeDirection.In);
|
||||
string pipename = UtilityProgram.GetPipeName();
|
||||
var p = UtilityProgram.CallWithAdmin("--extract-zip", pipename, installModDialog.FileName, "");
|
||||
var pipe = new NamedPipeClientStream(".", pipename, PipeDirection.In);
|
||||
pipe.Connect();
|
||||
|
||||
p.WaitForExit();
|
||||
@@ -199,5 +200,10 @@ namespace OpenRA.Launcher
|
||||
else
|
||||
Renderer = "Cg";
|
||||
}
|
||||
|
||||
void formClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +56,11 @@ namespace OpenRA.Launcher
|
||||
|
||||
static class UtilityProgram
|
||||
{
|
||||
public static string GetPipeName()
|
||||
{
|
||||
return "OpenRA.Utility" + Guid.NewGuid().ToString();
|
||||
}
|
||||
|
||||
static string BuildArgs(string command, string[] args)
|
||||
{
|
||||
StringBuilder arguments = new StringBuilder();
|
||||
@@ -66,11 +71,11 @@ namespace OpenRA.Launcher
|
||||
return arguments.ToString();
|
||||
}
|
||||
|
||||
public static Process Call(string command, params string[] args)
|
||||
public static Process Call(string command, string pipename, params string[] args)
|
||||
{
|
||||
Process p = new Process();
|
||||
p.StartInfo.FileName = "OpenRA.Utility.exe";
|
||||
p.StartInfo.Arguments = BuildArgs(command, args) + " --pipe";
|
||||
p.StartInfo.Arguments = BuildArgs(command, args) + " --pipe=" + pipename;
|
||||
p.StartInfo.UseShellExecute = false;
|
||||
p.StartInfo.CreateNoWindow = true;
|
||||
|
||||
@@ -81,9 +86,10 @@ namespace OpenRA.Launcher
|
||||
|
||||
public static string CallSimpleResponse(string command, params string[] args)
|
||||
{
|
||||
Call(command, args);
|
||||
string pipename = GetPipeName();
|
||||
Call(command, pipename, args);
|
||||
string responseString;
|
||||
NamedPipeClientStream pipe = new NamedPipeClientStream(".", "OpenRA.Utility", PipeDirection.In);
|
||||
NamedPipeClientStream pipe = new NamedPipeClientStream(".", pipename, PipeDirection.In);
|
||||
pipe.Connect();
|
||||
using (var response = new StreamReader(pipe))
|
||||
{
|
||||
@@ -93,11 +99,11 @@ namespace OpenRA.Launcher
|
||||
return responseString;
|
||||
}
|
||||
|
||||
public static Process CallWithAdmin(string command, params string[] args)
|
||||
public static Process CallWithAdmin(string command, string pipename, params string[] args)
|
||||
{
|
||||
Process p = new Process();
|
||||
p.StartInfo.FileName = "OpenRA.Utility.exe";
|
||||
p.StartInfo.Arguments = BuildArgs(command, args) + " --pipe";
|
||||
p.StartInfo.Arguments = BuildArgs(command, args) + " --pipe=" + pipename;
|
||||
p.StartInfo.Verb = "runas";
|
||||
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user