2009-05-26 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Tue, 26 May 2009 12:33:36 +0000 (12:33 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Tue, 26 May 2009 12:33:36 +0000 (12:33 -0000)
* TcpDuplexSessionChannel.cs : there was a miscalculation on the
  length of the SizedMessage in the output.

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

mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog
mcs/class/System.ServiceModel/System.ServiceModel.Channels/TcpDuplexSessionChannel.cs

index 1e64a9aa297c875b09dcb5025c453ea772f30c45..70d3578d89179a2d34d3332d1cd788bc1ef50713 100755 (executable)
@@ -1,3 +1,8 @@
+2009-05-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TcpDuplexSessionChannel.cs : there was a miscalculation on the
+         length of the SizedMessage in the output.
+
 2009-05-26  Atsushi Enomoto  <atsushi@ximian.com>
 
        * CommunicationObject.cs : use sane default timeout.
index a7ffa9d16de8f782a1cf1f0329d4a03122d3425a..45456912fb05bb9ee9ce2d1fec4d55abff428ad2 100644 (file)
@@ -284,6 +284,16 @@ namespace System.ServiceModel.Channels
                        {
                                Write7BitEncodedInt (value);
                        }
+
+                       public int GetSizeOfLength (int value)
+                       {
+                               int x = 0;
+                               do {
+                                       value /= 0x100;
+                                       x++;
+                               } while (value != 0);
+                               return x;
+                       }
                }
 
                class MyXmlBinaryWriterSession : XmlBinaryWriterSession
@@ -494,8 +504,13 @@ namespace System.ServiceModel.Channels
                        foreach (var ds in session.List)
                                dw.Write (ds.Value);
                        dw.Flush ();
-                       writer.WriteVariableInt ((int) (msd.Position + ms.Position));
-                       WriteSizedChunk (msd.ToArray ());
+
+                       int length = (int) (msd.Position + ms.Position);
+                       var msda = msd.ToArray ();
+                       int sizeOfLength = writer.GetSizeOfLength (msda.Length);
+
+                       writer.WriteVariableInt (length + sizeOfLength); // dictionary array also involves the size of itself.
+                       WriteSizedChunk (msda);
                        // message body
                        var arr = ms.GetBuffer ();
                        writer.Write (arr, 0, (int) ms.Position);