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 2011/01/30 02:04:14 UTC

svn commit: r1065155 - in /activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/main: activemq/wireformat/openwire/marshal/BaseDataStreamMarshaller.cpp decaf/lang/Thread.cpp

Author: tabish
Date: Sun Jan 30 01:04:14 2011
New Revision: 1065155

URL: http://svn.apache.org/viewvc?rev=1065155&view=rev
Log:
Backport fixes to 3.2.x fixes branch.  

Modified:
    activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/BaseDataStreamMarshaller.cpp
    activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/main/decaf/lang/Thread.cpp

Modified: activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/BaseDataStreamMarshaller.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/BaseDataStreamMarshaller.cpp?rev=1065155&r1=1065154&r2=1065155&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/BaseDataStreamMarshaller.cpp (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/main/activemq/wireformat/openwire/marshal/BaseDataStreamMarshaller.cpp Sun Jan 30 01:04:14 2011
@@ -286,7 +286,7 @@ void BaseDataStreamMarshaller::tightMars
                 dataOut->writeShort( (short)value.length() );
                 dataOut->writeBytes( value );
             } else {
-                dataOut->writeChars( value );
+                dataOut->writeUTF( value );
             }
         }
     }

Modified: activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/main/decaf/lang/Thread.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/main/decaf/lang/Thread.cpp?rev=1065155&r1=1065154&r2=1065155&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/main/decaf/lang/Thread.cpp (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/main/decaf/lang/Thread.cpp Sun Jan 30 01:04:14 2011
@@ -188,7 +188,9 @@ namespace{
             ThreadProperties::runCallback( properties );
 
             pthread_setspecific( currentThreadKey, NULL );
-            pthread_detach( properties->handle );
+
+            //pthread_detach( properties->handle );
+            pthread_exit(NULL);
 
             properties->state = Thread::TERMINATED;
 
@@ -331,6 +333,17 @@ void Thread::initialize( Runnable* task,
 ////////////////////////////////////////////////////////////////////////////////
 Thread::~Thread() {
     try{
+
+        // Don't join foreign threads on destruction, we don't control them.
+        if( properties->parent != NULL ) {
+            #ifdef HAVE_PTHREAD_H
+                void* theReturn = 0;
+                pthread_join( properties->handle, &theReturn );
+            #else
+                ::WaitForSingleObject( properties->handle, INFINITE );
+            #endif
+        }
+
         delete this->properties;
     }
     DECAF_CATCH_NOTHROW( Exception )
@@ -410,18 +423,18 @@ void Thread::start() throw ( decaf::lang
 ////////////////////////////////////////////////////////////////////////////////
 void Thread::join() throw( decaf::lang::exceptions::InterruptedException ) {
 
-    if( this->properties->state < Thread::RUNNABLE ) {
+    if( this->properties->state == Thread::TERMINATED ) {
         return;
     }
 
-    if( this->properties->state != Thread::TERMINATED ) {
+    synchronized( &this->properties->mutex ) {
 
-        #ifdef HAVE_PTHREAD_H
-            void* theReturn = 0;
-            pthread_join( properties->handle, &theReturn );
-        #else
-            ::WaitForSingleObject( properties->handle, INFINITE );
-        #endif
+        if( this->properties->state < Thread::RUNNABLE ||
+            this->properties->state == Thread::TERMINATED ) {
+            return;
+        }
+
+        this->properties->mutex.wait();
     }
 }
 
@@ -436,10 +449,6 @@ void Thread::join( long long millisecs )
             "Thread::join( millisecs ) - Value given {%d} is less than 0", millisecs );
     }
 
-    if( this->properties->state < Thread::RUNNABLE ) {
-        return;
-    }
-
     this->join( millisecs, 0 );
 }
 
@@ -460,9 +469,14 @@ void Thread::join( long long millisecs, 
             "Thread::join( millisecs, nanos ) - Nanoseconds must be in range [0...999999]" );
     }
 
+    if( this->properties->state == Thread::TERMINATED ) {
+        return;
+    }
+
     synchronized( &this->properties->mutex ) {
 
-        if( this->properties->state < Thread::RUNNABLE ) {
+        if( this->properties->state < Thread::RUNNABLE ||
+            this->properties->state == Thread::TERMINATED ) {
             return;
         }