activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r711699 - in /activemq/activemq-cpp/trunk/src/main/decaf/io: FilterInputStream.h FilterOutputStream.h
Date Wed, 05 Nov 2008 21:12:58 GMT
Author: tabish
Date: Wed Nov  5 13:12:58 2008
New Revision: 711699

URL: http://svn.apache.org/viewvc?rev=711699&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQCPP-200

Move deletion of buffer to the destructor, not the close method.

Modified:
    activemq/activemq-cpp/trunk/src/main/decaf/io/FilterInputStream.h
    activemq/activemq-cpp/trunk/src/main/decaf/io/FilterOutputStream.h

Modified: activemq/activemq-cpp/trunk/src/main/decaf/io/FilterInputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/io/FilterInputStream.h?rev=711699&r1=711698&r2=711699&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/io/FilterInputStream.h (original)
+++ activemq/activemq-cpp/trunk/src/main/decaf/io/FilterInputStream.h Wed Nov  5 13:12:58
2008
@@ -50,7 +50,7 @@
         bool own;
 
         // Indicates that this stream was closed
-        bool closed;
+        volatile bool closed;
 
     public:
 
@@ -68,6 +68,11 @@
         virtual ~FilterInputStream() {
             try {
                 this->close();
+
+                if( own ) {
+                    delete inputStream;
+                }
+                inputStream = NULL;
             }
             DECAF_CATCH_NOTHROW( IOException )
             DECAF_CATCHALL_NOTHROW( )
@@ -158,12 +163,8 @@
          */
         virtual void close() throw ( lang::Exception ) {
             try {
-                if( inputStream != NULL ) {
+                if( !closed && inputStream != NULL ) {
                     inputStream->close();
-                    if( own ) {
-                        delete inputStream;
-                    }
-                    inputStream = NULL;
                 }
                 this->closed = true;
             }

Modified: activemq/activemq-cpp/trunk/src/main/decaf/io/FilterOutputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/io/FilterOutputStream.h?rev=711699&r1=711698&r2=711699&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/io/FilterOutputStream.h (original)
+++ activemq/activemq-cpp/trunk/src/main/decaf/io/FilterOutputStream.h Wed Nov  5 13:12:58
2008
@@ -59,7 +59,7 @@
         bool own;
 
         // Indicates that this stream was closed
-        bool closed;
+        volatile bool closed;
 
     public:
 
@@ -78,6 +78,11 @@
         virtual ~FilterOutputStream() {
             try {
                 this->close();
+
+                if( own ) {
+                    delete outputStream;
+                }
+                outputStream = NULL;
             }
             DECAF_CATCH_NOTHROW( IOException )
             DECAF_CATCHALL_NOTHROW( )
@@ -195,13 +200,9 @@
          */
         virtual void close() throw ( lang::Exception ) {
             try {
-                if( outputStream != NULL ) {
+                if( !closed && outputStream != NULL ) {
                     outputStream->flush();
                     outputStream->close();
-                    if( own ) {
-                        delete outputStream;
-                    }
-                    outputStream = NULL;
                 }
                 this->closed = true;
             }



Mime
View raw message