[Mono-bugs] [Bug 75526][Nor] Changed - [PATCH] StreamReader blocks on reading too much

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Tue Jan 23 21:09:48 EST 2007


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by miguel at ximian.com.

http://bugzilla.ximian.com/show_bug.cgi?id=75526

--- shadow/75526	2007-01-23 15:07:48.000000000 -0500
+++ shadow/75526.tmp.5491	2007-01-23 21:09:48.000000000 -0500
@@ -185,6 +185,37 @@
 
 
 ------- Additional Comments From jlarimer at gmail.com  2007-01-23 15:07 -------
 Created an attachment (id=18542)
 Proposed patch for StreamReader.cs
 
+
+------- Additional Comments From miguel at ximian.com  2007-01-23 21:09 -------
+This patch is not correct, because it will limit reads to the internal
+size of the buffer, instead of all the data requested, the following
+program illustrates the problem:
+
+bash$ dd if=/dev/zero of=/tmp/sample bs=8192 count=10
+10+0 records in
+10+0 records out
+81920 bytes (82 kB) copied, 0.000457 seconds, 179 MB/s
+bash$ mcs demo.cs
+bash$ mono demo.exe
+Read 1024 bytes
+bash$ cat demo.cs
+using System;
+using System.IO;
+
+class X {
+        static void Main ()
+        {
+                FileStream f = File.OpenRead ("/tmp/sample");
+
+                StreamReader sr = new StreamReader (f);
+                char [] buf = new char [8192];
+                int len = sr.Read(buf, 0, buf.Length);
+                Console.WriteLine ("Read {0} bytes", len);
+        }
+}
+
+Which means that the code must loop.
+


More information about the mono-bugs mailing list