Stop UnixStream.Dispose() throwing if the stream is already closed.
authorRichard Kettlewell <rjk@terraraq.org.uk>
Sat, 11 Feb 2012 23:03:49 +0000 (23:03 +0000)
committerRichard Kettlewell <rjk@terraraq.org.uk>
Sat, 11 Feb 2012 23:03:49 +0000 (23:03 +0000)
This (re-)establishes the invariant that once the object has been
constructed it can be disposed, making it suitable for use in 'using'
statements; and allows it to be used with a StreamReader in the same
way as other stream classes.

mcs/class/Mono.Posix/Mono.Unix/UnixStream.cs

index e2f143b5c69842f3f4774a994fe189265f3abf32..8a94a7d19edcb6b7f1aef02daaeefbe466fed181 100644 (file)
@@ -417,8 +417,7 @@ namespace Mono.Unix {
                
                void IDisposable.Dispose ()
                {
-                       AssertNotDisposed ();
-                       if (owner) {
+                       if (fileDescriptor != InvalidFileDescriptor && owner) {
                                Close ();
                        }
                        GC.SuppressFinalize (this);