[Mono-bugs] [Bug 37045][Nor] New - Problem closing Streams

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Wed, 22 Jan 2003 05:29:16 -0500 (EST)


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 carlosga@telefonica.net.

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

--- shadow/37045	Wed Jan 22 05:29:16 2003
+++ shadow/37045.tmp.31792	Wed Jan 22 05:29:16 2003
@@ -0,0 +1,122 @@
+Bug#: 37045
+Product: Mono/Class Libraries
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: carlosga@telefonica.net               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary:  Problem closing Streams
+
+Hello:
+
+
+I´m making test of the Firebird ADO.NET provider on linux Red Hat 8.0 with
+the latest sources of mono, i have a problem, I have BinaryReader used for
+reading data sent by the server, and a BinaryWriter for send data to the
+server created as:
+
+    db.Output = new XdrOutputStream(new
+BufferedStream((System.IO.Stream)db.DbNetworkStream));
+    
+    db.Input  = new XdrInputStream(new
+BufferedStream((System.IO.Stream)db.DbNetworkStream));
+
+
+When i disconnect from a database i make:
+
+    db.Input.Close();
+    db.Output.Close();  // Here gives an exception
+    db.DbNetworkStream.Close();
+    ...
+
+
+This works well on Ms .Net, and it has been working well on old versions of
+mono (0.17).
+
+
+
+The exception is:
+
+Unhandled Exception: System.ObjectDisposedException: The object was used
+after being disposed
+in <0x00094> 00 System.Net.Sockets.NetworkStream:CheckDisposed ()
+in <0x00186> 00 System.Net.Sockets.NetworkStream:Write (byte[],int,int)
+in <0x00181> 00 System.IO.BufferedStream:Flush ()
+in <0x00014> 00 System.IO.BufferedStream:Close ()
+in <0x00052> 00 System.IO.BinaryWriter:Dispose (bool)
+in <0x00019> 00 System.IO.BinaryWriter:Close ()
+in <0x000a7> 00 FirebirdSql.Data.NGDS.isc_db_handle_impl:Invalidate ()
+in <0x0005a> 00 FirebirdSql.Data.NGDS.GDS:Disconnect
+(FirebirdSql.Data.NGDS.isc_db_handle_impl)
+in <0x00224> 00 FirebirdSql.Data.NGDS.GDS:isc_detach_database
+(FirebirdSql.Data.INGDS.isc_db_handle)
+in <0x0003b> 00 FirebirdSql.Data.Firebird.FbIscConnection:Close ()
+in <0x0024c> 00 FirebirdSql.Data.Firebird.FbConnection:Close ()
+in <0x0001f> 00 AS3AP.BenckMark.FirebirdBackend:DatabaseDisconnect ()
+in <0x00068> 00 AS3AP.BenckMark.FirebirdBackend:DatabaseDisconnect ()
+in <0x000fc> 00 AS3AP.BenckMark.Benchmark:Main (string[])
+
+
+
+
+
+TEST CASE:
+
+using System;
+using System.IO;
+using System.Net;
+using System.Net.Sockets;
+
+namespace Test.Stream
+{
+	public class Test
+	{
+		public static void Main(string[] args)
+		{
+			BinaryWriter	output;
+			BinaryReader	input;
+
+			Socket			socket;
+			NetworkStream	networkStream;
+
+			IPAddress	hostadd = Dns.Resolve("localhost").AddressList[0];
+			IPEndPoint	EPhost = new IPEndPoint(hostadd, 3050);
+			socket = new Socket(AddressFamily.InterNetwork,
+								SocketType.Stream,
+								ProtocolType.IP);
+
+			socket.Connect(EPhost);					
+			networkStream = new NetworkStream(socket, true);	
+
+			output = new BinaryWriter(new
+BufferedStream((System.IO.Stream)networkStream));    
+			input  = new BinaryReader(new
+BufferedStream((System.IO.Stream)networkStream));
+
+			input.Close();
+			Console.WriteLine("input Closed");
+			output.Close();
+			Console.WriteLine("output Closed");
+			networkStream.Close();
+			Console.WriteLine("networkStream Closed");
+			socket.Close();
+			Console.WriteLine("socket Closed");
+		}
+	}
+}
+
+
+
+
+Best regards
+Carlos Guzmán álvarez
+Vigo-Spain