From 0617642a9549e25caa679bb47449d25c6a3863a8 Mon Sep 17 00:00:00 2001 From: Robert Jordan Date: Sun, 8 Aug 2010 02:15:37 +0800 Subject: [PATCH] [Fix] Handle the portName argument/property properly. Some of IpcServerChannel's ctors did not keep track of the original IPC port name correctly. This led to a non-functional GetUrlsForUri method. --- .../IpcServerChannel.cs | 8 ++-- .../Test/IpcChannelTest.cs | 45 +++++++++++++++++++ 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Ipc.Unix/IpcServerChannel.cs b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Ipc.Unix/IpcServerChannel.cs index 2941cd0b24c..34bbcf7e49d 100644 --- a/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Ipc.Unix/IpcServerChannel.cs +++ b/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Ipc.Unix/IpcServerChannel.cs @@ -55,13 +55,12 @@ namespace System.Runtime.Remoting.Channels.Ipc.Unix Hashtable h = new Hashtable (); foreach (DictionaryEntry e in props) { + h [e.Key] = e.Value; + switch (e.Key as string) { case "portName": h ["path"] = BuildPathFromPortName ((string)e.Value); break; - default: - h [e.Key] = e.Value; - break; } } return h; @@ -86,7 +85,8 @@ namespace System.Runtime.Remoting.Channels.Ipc.Unix public IpcServerChannel (string name, string portName) { - _portName = portName = BuildPathFromPortName (portName); + _portName = portName; + _path = portName = BuildPathFromPortName (portName); _innerChannel = Activator.CreateInstance(UnixChannelLoader.LoadServerChannel (), new object [] {name, portName}); } diff --git a/mcs/class/System.Runtime.Remoting/Test/IpcChannelTest.cs b/mcs/class/System.Runtime.Remoting/Test/IpcChannelTest.cs index 394e8f00c4a..74d97cdf10a 100644 --- a/mcs/class/System.Runtime.Remoting/Test/IpcChannelTest.cs +++ b/mcs/class/System.Runtime.Remoting/Test/IpcChannelTest.cs @@ -67,6 +67,51 @@ namespace MonoTests.Remoting return payload; } } + + [Test] + public void TestCtor2 () + { + string channelName = Guid.NewGuid ().ToString ("N"); + string portName = "ipc" + Guid.NewGuid ().ToString ("N"); + string url = String.Format ("ipc://{0}/server.rem", portName); + + IpcServerChannel chan = new IpcServerChannel (channelName, portName); + string[] uris = chan.GetUrlsForUri ("server.rem"); + Assert.IsNotNull (uris); + Assert.Greater (uris.Length, 0); + + bool found = false; + foreach (string s in uris) { + if (s == url) { + found = true; + break; + } + } + Assert.IsTrue (found); + } + + [Test] + public void TestCtor3 () + { + string portName = "ipc" + Guid.NewGuid ().ToString ("N"); + string url = String.Format ("ipc://{0}/server.rem", portName); + + Hashtable props = new Hashtable (); + props ["portName"] = portName; + IpcChannel chan = new IpcChannel (props, null, null); + string[] uris = chan.GetUrlsForUri ("server.rem"); + Assert.IsNotNull (uris); + Assert.Greater (uris.Length, 0); + + bool found = false; + foreach (string s in uris) { + if (s == url) { + found = true; + break; + } + } + Assert.IsTrue (found); + } } } -- 2.25.1