In Test:
authorRobert Jordan <robertj@gmx.net>
Sat, 29 May 2010 16:37:13 +0000 (16:37 -0000)
committerRobert Jordan <robertj@gmx.net>
Sat, 29 May 2010 16:37:13 +0000 (16:37 -0000)
2010-05-29  Robert Jordan  <robertj@gmx.net>

* IpcChannelTest.cs: Add test for bug #609381.

In System.Runtime.Remoting.Channels.Ipc.Win32:
2010-05-29  Robert Jordan  <robertj@gmx.net>

* IpcChannelHelper.cs (copy): Take into account that the remoting
stack is internally using MemoryStreams all over the place.
Fixes bug #609381 as a side effect.

* IpcChannel.cs (.ctor): Create an IpcClientChannel as well.

svn path=/trunk/mcs/; revision=158161

mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Ipc.Win32/ChangeLog
mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Ipc.Win32/IpcChannel.cs
mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Ipc.Win32/IpcChannelHelper.cs
mcs/class/System.Runtime.Remoting/Test/ChangeLog
mcs/class/System.Runtime.Remoting/Test/IpcChannelTest.cs

index 2bf20ad53b2ccb3881fe33f4729debe130b876c4..02fee79aaefc5ef93a8e40d26131c4b3dc54ebbb 100644 (file)
@@ -1,3 +1,11 @@
+2010-05-29  Robert Jordan  <robertj@gmx.net>
+
+       * IpcChannelHelper.cs (copy): Take into account that the remoting
+       stack is internally using MemoryStreams all over the place.
+       Fixes bug #609381 as a side effect.
+
+       * IpcChannel.cs (.ctor): Create an IpcClientChannel as well.
+
 2005-11-05  Robert Jordan  <robertj@gmx.net>
 
        * IpcClientChannel.cs, IpcServerChannel.cs: Added missing ctors.
index a311ed1180f98d626e7feefe0f1b0a388f82498e..5cb721944f40e2a5c328fb4ea64ef307c0678851 100644 (file)
@@ -53,7 +53,8 @@ namespace System.Runtime.Remoting.Channels.Ipc.Win32
         /// Creates a server channel.
         /// </summary>
         /// <param name="portName">The port name.</param>
-        public IpcChannel(string portName) 
+        public IpcChannel(string portName)
+           : this()
         {
             serverChannel = new IpcServerChannel(portName);
         }
index 55210c6cd880af71d892d1d0a44c42cc74cf3fa8..6b018b035f46cfca6ed601f59e506b2fdbebf4ce 100644 (file)
@@ -117,18 +117,25 @@ namespace System.Runtime.Remoting.Channels.Ipc.Win32
         /// <summary>
         /// Copies a stream.
         /// </summary>
-        /// <param name="from"></param>
-        /// <param name="to"></param>
-        public static void Copy(Stream from, Stream to
+        /// <param name="input"></param>
+        /// <param name="output"></param>
+        public static void Copy(Stream input, Stream output
         {
+            MemoryStream ms = input as MemoryStream;
+           if (ms != null)
+           {
+               ms.WriteTo (output);
+               return;
+           }
+
             // TODO: find out the optimal chunk size.
             const int size = 1024 * 1024;
             byte[] buffer = new byte[size];
 
             int count;
-            while ((count = from.Read(buffer, 0, size)) > 0)
+            while ((count = input.Read(buffer, 0, size)) > 0)
             {
-                to.Write(buffer, 0, count);
+                output.Write(buffer, 0, count);
             }
         }
 
index 8b3c8e5c94af41798e1c96852320fc6cbad1d395..cd19e34c0c798c4cd8df4c3e0aaf216d4ab751a3 100644 (file)
@@ -1,3 +1,7 @@
+2010-05-29  Robert Jordan  <robertj@gmx.net>
+
+       * IpcChannelTest.cs: Add test for bug #609381.
+
 2010-02-28  Robert Jordan  <robertj@gmx.net>
 
        * BaseCalls.cs: Enable tests again. See bug #576618.
index 338e3b7069763fbc85afc028b41dccc8d9edc09f..394e8f00c4ae7be68b2e1e4d2b2806267746d1ec 100644 (file)
@@ -27,6 +27,46 @@ namespace MonoTests.Remoting
                        string objectUri;
                        c.CreateMessageSink (null, cd, out objectUri);
                }
+
+               [Test]
+               public void Bug609381 ()
+               {
+                       string portName = "ipc" + Guid.NewGuid ().ToString ("N");
+                       string objUri = "ipcserver609381.rem";
+                       string url = String.Format ("ipc://{0}/{1}", portName, objUri);
+
+                       IpcChannel serverChannel = new IpcChannel (portName);
+                       ChannelServices.RegisterChannel (serverChannel);
+
+                       RemotingServices.Marshal (new Server (), objUri);
+
+                       Server client = (Server) RemotingServices.Connect (typeof (Server), url);
+                       
+                       int count = 10 * 1024 * 1024;
+                       byte[] sendBuf = new byte[count];
+                       sendBuf [sendBuf.Length - 1] = 41;
+                       
+                       byte[] recvBuf = client.Send (sendBuf);
+
+                       Assert.IsNotNull (recvBuf);
+                       Assert.AreNotSame (sendBuf, recvBuf);
+                       Assert.AreEqual (count, recvBuf.Length);
+                       Assert.AreEqual (42, recvBuf [recvBuf.Length - 1]);
+
+                       sendBuf = null;
+                       recvBuf = null;
+
+                       ChannelServices.UnregisterChannel (serverChannel);
+               }
+
+               class Server : MarshalByRefObject
+               {
+                       public byte[] Send (byte[] payload)
+                       {
+                               payload [payload.Length - 1]++;
+                               return payload;
+                       }
+               }
        }
 }