You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2012/10/05 21:08:00 UTC

svn commit: r1394738 - /activemq/activemq-cpp/branches/activemq-cpp-3.4.x/activemq-cpp/src/main/activemq/transport/IOTransport.cpp

Author: tabish
Date: Fri Oct  5 19:08:00 2012
New Revision: 1394738

URL: http://svn.apache.org/viewvc?rev=1394738&view=rev
Log:
better close exception handling.  

Modified:
    activemq/activemq-cpp/branches/activemq-cpp-3.4.x/activemq-cpp/src/main/activemq/transport/IOTransport.cpp

Modified: activemq/activemq-cpp/branches/activemq-cpp-3.4.x/activemq-cpp/src/main/activemq/transport/IOTransport.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-3.4.x/activemq-cpp/src/main/activemq/transport/IOTransport.cpp?rev=1394738&r1=1394737&r2=1394738&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-3.4.x/activemq-cpp/src/main/activemq/transport/IOTransport.cpp (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-3.4.x/activemq-cpp/src/main/activemq/transport/IOTransport.cpp Fri Oct  5 19:08:00 2012
@@ -213,22 +213,43 @@ void IOTransport::close() {
 		// No need to fire anymore async events now.
 		this->listener = NULL;
 
-		// We have to close the input stream before we stop the thread.  this will
-		// force us to wake up the thread if it's stuck in a read (which is likely).
-		// Otherwise, the join that follows will block forever.
-		if (inputStream != NULL) {
-			inputStream->close();
-			inputStream = NULL;
-		}
-
-		// Close the output stream.
-		if (outputStream != NULL) {
-			outputStream->close();
-			outputStream = NULL;
-		}
+        IOException error;
+        bool hasException = false;
 
-		// Clear the WireFormat so we can't use it anymore
-		this->wireFormat.reset(NULL);
+        // We have to close the input stream before we stop the thread.  this will
+        // force us to wake up the thread if it's stuck in a read (which is likely).
+        // Otherwise, the join that follows will block forever.
+        try {
+            if (inputStream != NULL) {
+                inputStream->close();
+                inputStream = NULL;
+            }
+        } catch (IOException& ex) {
+            error = ex;
+            error.setMark(__FILE__, __LINE__);
+            hasException = true;
+        }
+
+        try {
+            // Close the output stream.
+            if (outputStream != NULL) {
+                outputStream->close();
+                outputStream = NULL;
+            }
+        } catch (IOException& ex) {
+            if (!hasException) {
+                error = ex;
+                error.setMark(__FILE__, __LINE__);
+                hasException = true;
+            }
+        }
+
+        // Clear the WireFormat so we can't use it anymore
+        this->wireFormat.reset(NULL);
+
+        if (hasException) {
+            throw error;
+        }
 	}
     AMQ_CATCH_RETHROW( IOException )
     AMQ_CATCH_EXCEPTION_CONVERT( Exception, IOException )