+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.
/// 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);
}
/// <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);
}
}
+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.
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;
+ }
+ }
}
}