activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r711441 - in /activemq/activemq-cpp/trunk/src/main/decaf/net: SocketInputStream.cpp SocketOutputStream.cpp
Date Tue, 04 Nov 2008 22:04:16 GMT
Author: tabish
Date: Tue Nov  4 14:04:16 2008
New Revision: 711441

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

Add additional checks to detect a closed stream and not attempt to use a closed socket.

Modified:
    activemq/activemq-cpp/trunk/src/main/decaf/net/SocketInputStream.cpp
    activemq/activemq-cpp/trunk/src/main/decaf/net/SocketOutputStream.cpp

Modified: activemq/activemq-cpp/trunk/src/main/decaf/net/SocketInputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/net/SocketInputStream.cpp?rev=711441&r1=711440&r2=711441&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/net/SocketInputStream.cpp (original)
+++ activemq/activemq-cpp/trunk/src/main/decaf/net/SocketInputStream.cpp Tue Nov  4 14:04:16
2008
@@ -70,6 +70,13 @@
 ////////////////////////////////////////////////////////////////////////////////
 std::size_t SocketInputStream::available() const throw ( io::IOException ){
 
+    // Check for a closed call from socket class, if closed then this read fails.
+    if( closed ){
+        throw IOException(
+            __FILE__, __LINE__,
+            "decaf::io::SocketInputStream::available - The stream is closed" );
+    }
+
     // Convert to an OS level socket.
     apr_os_sock_t oss;
     apr_os_sock_get( (apr_os_sock_t*)&oss, socket );
@@ -129,6 +136,13 @@
 ////////////////////////////////////////////////////////////////////////////////
 unsigned char SocketInputStream::read() throw ( IOException ){
 
+    // Check for a closed call from socket class, if closed then this read fails.
+    if( closed ){
+        throw IOException(
+            __FILE__, __LINE__,
+            "decaf::io::SocketInputStream::read - The Stream has been closed" );
+    }
+
     apr_status_t result = APR_SUCCESS;
     char c;
     apr_size_t size = 1;
@@ -149,6 +163,13 @@
                              std::size_t bufferSize )
     throw ( IOException, lang::exceptions::NullPointerException ) {
 
+    // Check for a closed call from socket class, if closed then this read fails.
+    if( closed ){
+        throw IOException(
+            __FILE__, __LINE__,
+            "decaf::io::SocketInputStream::read - The Stream has been closed" );
+    }
+
     apr_size_t size = (apr_size_t)bufferSize;
     apr_status_t result = APR_SUCCESS;
 
@@ -167,7 +188,7 @@
     if( closed ){
         throw IOException(
             __FILE__, __LINE__,
-            "activemq::io::SocketInputStream::read - The connection is broken" );
+            "decaf::io::SocketInputStream::read - The connection is broken" );
     }
 
     // Check for error.

Modified: activemq/activemq-cpp/trunk/src/main/decaf/net/SocketOutputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/net/SocketOutputStream.cpp?rev=711441&r1=711440&r2=711441&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/net/SocketOutputStream.cpp (original)
+++ activemq/activemq-cpp/trunk/src/main/decaf/net/SocketOutputStream.cpp Tue Nov  4 14:04:16
2008
@@ -79,6 +79,12 @@
             "SocketOutputStream::write - passed buffer is null" );
     }
 
+    if( closed ) {
+        throw IOException(
+            __FILE__, __LINE__,
+            "decaf::net::SocketOutputStream::write - This Stream has been closed." );
+    }
+
     apr_size_t remaining = (apr_size_t)len;
     apr_status_t result = APR_SUCCESS;
 



Mime
View raw message