[Fix] Handle the portName argument/property properly.
authorRobert Jordan <robertj@gmx.net>
Sat, 7 Aug 2010 18:15:37 +0000 (02:15 +0800)
committerLluis Sanchez <slluis.devel@gmail.com>
Wed, 11 Aug 2010 16:53:27 +0000 (00:53 +0800)
Some of IpcServerChannel's ctors did not keep track of the original
IPC port name correctly. This led to a non-functional GetUrlsForUri
method.

mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Ipc.Unix/IpcServerChannel.cs
mcs/class/System.Runtime.Remoting/Test/IpcChannelTest.cs

index 2941cd0b24c4c1d30481dbc8c5337ab553a2bd45..34bbcf7e49dcb498c471d1b3bbde203994f62277 100644 (file)
@@ -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});
                 }
index 394e8f00c4ae7be68b2e1e4d2b2806267746d1ec..74d97cdf10aba2efabb103abd134a46727bb0f1f 100644 (file)
@@ -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);
+               }
        }
 }