Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make IPC port configurable via HostOptions #6129

Merged
merged 5 commits into from
Jan 15, 2024

Conversation

tsunyoku
Copy link
Member

@tsunyoku tsunyoku commented Jan 12, 2024

Resolves #6127

Breaking changes

HostOptions.BindIPC has been superseded by HostOptions.IPCPort

Previously, the IPC port used for multiple instances of a single osu!framework app was hardcoded in the IPC host itself, effectively making it so that all osu!framework apps would share the same IPC port, which obviously cannot work.

To allow multiple osu!framework apps to utilise IPC concurrently, BindIPC has thus been replaced by IPCPort.

  • Setting IPCPort = null is equivalent to BindIPC = false.
  • Setting IPCPort to a non-null value is equivalent to BindIPC = true and will force the use the specific port provided.

Note that it is advised to use a "user port" (in the range of 1024-49151) as per RFC 6335.

osu.Framework/HostOptions.cs Outdated Show resolved Hide resolved
osu.Framework/HostOptions.cs Outdated Show resolved Hide resolved
@bdach
Copy link
Collaborator

bdach commented Jan 15, 2024

Baseline changes to apply game-side after this:

diff --git a/Templates/Rulesets/ruleset-empty/osu.Game.Rulesets.EmptyFreeform.Tests/VisualTestRunner.cs b/Templates/Rulesets/ruleset-empty/osu.Game.Rulesets.EmptyFreeform.Tests/VisualTestRunner.cs
index 03ee7c9204..8b7a3e6045 100644
--- a/Templates/Rulesets/ruleset-empty/osu.Game.Rulesets.EmptyFreeform.Tests/VisualTestRunner.cs
+++ b/Templates/Rulesets/ruleset-empty/osu.Game.Rulesets.EmptyFreeform.Tests/VisualTestRunner.cs
@@ -13,7 +13,7 @@ public static class VisualTestRunner
         [STAThread]
         public static int Main(string[] args)
         {
-            using (DesktopGameHost host = Host.GetSuitableDesktopHost(@"osu", new HostOptions { BindIPC = true }))
+            using (DesktopGameHost host = Host.GetSuitableDesktopHost(@"osu", new HostOptions { IPCPort = 45356 }))
             {
                 host.Run(new OsuTestBrowser());
                 return 0;
diff --git a/Templates/Rulesets/ruleset-example/osu.Game.Rulesets.Pippidon.Tests/VisualTestRunner.cs b/Templates/Rulesets/ruleset-example/osu.Game.Rulesets.Pippidon.Tests/VisualTestRunner.cs
index 55c0cf6a3b..8a270bf5f0 100644
--- a/Templates/Rulesets/ruleset-example/osu.Game.Rulesets.Pippidon.Tests/VisualTestRunner.cs
+++ b/Templates/Rulesets/ruleset-example/osu.Game.Rulesets.Pippidon.Tests/VisualTestRunner.cs
@@ -13,7 +13,7 @@ public static class VisualTestRunner
         [STAThread]
         public static int Main(string[] args)
         {
-            using (DesktopGameHost host = Host.GetSuitableDesktopHost(@"osu", new HostOptions { BindIPC = true }))
+            using (DesktopGameHost host = Host.GetSuitableDesktopHost(@"osu", new HostOptions { IPCPort = 45356 }))
             {
                 host.Run(new OsuTestBrowser());
                 return 0;
diff --git a/Templates/Rulesets/ruleset-scrolling-empty/osu.Game.Rulesets.EmptyScrolling.Tests/VisualTestRunner.cs b/Templates/Rulesets/ruleset-scrolling-empty/osu.Game.Rulesets.EmptyScrolling.Tests/VisualTestRunner.cs
index b45505678c..f2fafee414 100644
--- a/Templates/Rulesets/ruleset-scrolling-empty/osu.Game.Rulesets.EmptyScrolling.Tests/VisualTestRunner.cs
+++ b/Templates/Rulesets/ruleset-scrolling-empty/osu.Game.Rulesets.EmptyScrolling.Tests/VisualTestRunner.cs
@@ -13,7 +13,7 @@ public static class VisualTestRunner
         [STAThread]
         public static int Main(string[] args)
         {
-            using (DesktopGameHost host = Host.GetSuitableDesktopHost(@"osu", new HostOptions { BindIPC = true }))
+            using (DesktopGameHost host = Host.GetSuitableDesktopHost(@"osu", new HostOptions { IPCPort = 45356 }))
             {
                 host.Run(new OsuTestBrowser());
                 return 0;
diff --git a/Templates/Rulesets/ruleset-scrolling-example/osu.Game.Rulesets.Pippidon.Tests/VisualTestRunner.cs b/Templates/Rulesets/ruleset-scrolling-example/osu.Game.Rulesets.Pippidon.Tests/VisualTestRunner.cs
index 55c0cf6a3b..8a270bf5f0 100644
--- a/Templates/Rulesets/ruleset-scrolling-example/osu.Game.Rulesets.Pippidon.Tests/VisualTestRunner.cs
+++ b/Templates/Rulesets/ruleset-scrolling-example/osu.Game.Rulesets.Pippidon.Tests/VisualTestRunner.cs
@@ -13,7 +13,7 @@ public static class VisualTestRunner
         [STAThread]
         public static int Main(string[] args)
         {
-            using (DesktopGameHost host = Host.GetSuitableDesktopHost(@"osu", new HostOptions { BindIPC = true }))
+            using (DesktopGameHost host = Host.GetSuitableDesktopHost(@"osu", new HostOptions { IPCPort = 45356 }))
             {
                 host.Run(new OsuTestBrowser());
                 return 0;
diff --git a/osu.Desktop/Program.cs b/osu.Desktop/Program.cs
index 6b95a82703..ef3aff6bdf 100644
--- a/osu.Desktop/Program.cs
+++ b/osu.Desktop/Program.cs
@@ -102,7 +102,7 @@ public static void Main(string[] args)
                 }
             }
 
-            using (DesktopGameHost host = Host.GetSuitableDesktopHost(gameName, new HostOptions { BindIPC = !tournamentClient }))
+            using (DesktopGameHost host = Host.GetSuitableDesktopHost(gameName, new HostOptions { IPCPort = tournamentClient ? null : 45356 }))
             {
                 if (!host.IsPrimaryInstance)
                 {
diff --git a/osu.Game.Tests/Visual/Navigation/TestSceneInterProcessCommunication.cs b/osu.Game.Tests/Visual/Navigation/TestSceneInterProcessCommunication.cs
index 1ecd38e1d3..85531b66a2 100644
--- a/osu.Game.Tests/Visual/Navigation/TestSceneInterProcessCommunication.cs
+++ b/osu.Game.Tests/Visual/Navigation/TestSceneInterProcessCommunication.cs
@@ -63,7 +63,7 @@ public override void SetUpSteps()
             });
             AddStep("create IPC sender channels", () =>
             {
-                ipcSenderHost = new HeadlessGameHost(gameHost.Name, new HostOptions { BindIPC = true });
+                ipcSenderHost = new HeadlessGameHost(gameHost.Name, new HostOptions { IPCPort = 45356 });
                 osuSchemeLinkIPCSender = new OsuSchemeLinkIPCChannel(ipcSenderHost);
                 archiveImportIPCSender = new ArchiveImportIPCChannel(ipcSenderHost);
             });
diff --git a/osu.Game.Tournament.Tests/TournamentTestRunner.cs b/osu.Game.Tournament.Tests/TournamentTestRunner.cs
index 5f642b14f5..1d38648243 100644
--- a/osu.Game.Tournament.Tests/TournamentTestRunner.cs
+++ b/osu.Game.Tournament.Tests/TournamentTestRunner.cs
@@ -12,7 +12,7 @@ public static class TournamentTestRunner
         [STAThread]
         public static int Main(string[] args)
         {
-            using (DesktopGameHost host = Host.GetSuitableDesktopHost(@"osu-development", new HostOptions { BindIPC = true }))
+            using (DesktopGameHost host = Host.GetSuitableDesktopHost(@"osu-development", new HostOptions { IPCPort = 45356 }))
             {
                 host.Run(new TournamentTestBrowser());
                 return 0;
diff --git a/osu.Game/Tests/CleanRunHeadlessGameHost.cs b/osu.Game/Tests/CleanRunHeadlessGameHost.cs
index f3c69201e2..6a5c756a9e 100644
--- a/osu.Game/Tests/CleanRunHeadlessGameHost.cs
+++ b/osu.Game/Tests/CleanRunHeadlessGameHost.cs
@@ -27,7 +27,7 @@ public class CleanRunHeadlessGameHost : TestRunHeadlessGameHost
                                         [CallerMemberName] string callingMethodName = @"")
             : base($"{callingMethodName}-{Guid.NewGuid()}", new HostOptions
             {
-                BindIPC = bindIPC,
+                IPCPort = 45356,
             }, bypassCleanup: bypassCleanupOnDispose, realtime: realtime)
         {
             this.bypassCleanupOnSetup = bypassCleanupOnSetup;
diff --git a/osu.Game/Tests/VisualTestRunner.cs b/osu.Game/Tests/VisualTestRunner.cs
index e04c71d193..c6a0eaf9bd 100644
--- a/osu.Game/Tests/VisualTestRunner.cs
+++ b/osu.Game/Tests/VisualTestRunner.cs
@@ -12,7 +12,7 @@ public static class VisualTestRunner
         [STAThread]
         public static int Main(string[] args)
         {
-            using (DesktopGameHost host = Host.GetSuitableDesktopHost(@"osu-development", new HostOptions { BindIPC = true, }))
+            using (DesktopGameHost host = Host.GetSuitableDesktopHost(@"osu-development", new HostOptions { IPCPort = 45356, }))
             {
                 host.Run(new OsuTestBrowser());
                 return 0;

May want to change the visual test runner port to be able to run that independently of game, not sure. The above is the minimal viable.

@bdach bdach enabled auto-merge January 15, 2024 21:01
@bdach bdach merged commit 7cf027f into ppy:master Jan 15, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to open more than one osu!framework based project at the same time
4 participants