summaryrefslogtreecommitdiff
path: root/TAO
diff options
context:
space:
mode:
authorOssama Othman <ossama-othman@users.noreply.github.com>2002-03-07 05:56:32 +0000
committerOssama Othman <ossama-othman@users.noreply.github.com>2002-03-07 05:56:32 +0000
commitdaa29310c24eee0428f16fd5e446db40e25898e3 (patch)
tree3ac5ebd70a214ba71113affb2a0aaa4eca5e58fa /TAO
parent21841fd166725fd06b39ec958e4264a586e0121e (diff)
downloadATCD-daa29310c24eee0428f16fd5e446db40e25898e3.tar.gz
ChangeLogTag:Wed Mar 6 21:55:11 2002 Ossama Othman <ossama@uci.edu>
Diffstat (limited to 'TAO')
-rw-r--r--TAO/ChangeLogs/ChangeLog-02a16
-rw-r--r--TAO/tao/Object.cpp33
-rw-r--r--TAO/tao/Stub.h27
-rw-r--r--TAO/tao/Stub.i21
4 files changed, 87 insertions, 10 deletions
diff --git a/TAO/ChangeLogs/ChangeLog-02a b/TAO/ChangeLogs/ChangeLog-02a
index 22564acb747..992d12dbcf3 100644
--- a/TAO/ChangeLogs/ChangeLog-02a
+++ b/TAO/ChangeLogs/ChangeLog-02a
@@ -1,7 +1,20 @@
+Wed Mar 6 21:55:11 2002 Ossama Othman <ossama@uci.edu>
+
+ * tao/Object.cpp (_remove_ref):
+
+ Fixed a race condition, and an extraneous lock used upon object
+ reference destruction.
+
+ * tao/Stub.h:
+ * tao/Stub.i (refcount_lock, refcount, destroy):
+
+ New accessors used by the CORBA::Object::_remove_ref()
+ implementation.
+
Wed Mar 06 18:59:37 2002 Jaiganesh Balasubramanian <jai@doc.ece.uci.edu>
* examples/AMI/FL_Callback/AMI_Peer.dsp:
- * examples/AMI/FL_Callback/AMI_Progress.dsp:
+ * examples/AMI/FL_Callback/AMI_Progress.dsp:
* performance-tests/Latency/AMH/Single_Threaded/client.dsp:
* performance-tests/Latency/AMH/Single_Threaded/server.dsp:
* performance-tests/Latency/DII/client.dsp:
@@ -38,6 +51,7 @@ Wed Mar 6 14:32:00 2002 Jaiganesh Balasubramanian <jai@doc.ece.uci.edu>
* tao/Messaging/MessagingC.cpp:
Made changes to fix the Debbian_KCC builds.
+>>>>>>> 1.5174
Wed Mar 6 11:03:12 2002 Ossama Othman <ossama@uci.edu>
* orbsvcs/orbsvcs/FaultTolerance/FT_IOGR_Property.h:
diff --git a/TAO/tao/Object.cpp b/TAO/tao/Object.cpp
index e2233178c4f..aa72b7a4cf8 100644
--- a/TAO/tao/Object.cpp
+++ b/TAO/tao/Object.cpp
@@ -1,6 +1,7 @@
// @(#) $Id$
//
// Copyright 1994-1995 by Sun Microsystems Inc.
+// Copyright 1997-2002 by Washington University
// All Rights Reserved
//
// ORB: CORBA_Object operations
@@ -70,14 +71,30 @@ CORBA_Object::_add_ref (void)
void
CORBA_Object::_remove_ref (void)
{
- // Note that we check if the reference count in the TAO_Stub is one
- // instead of zero since the reference count was increased by one in
- // the CORBA::Object constructor. This object's destructor cleans
- // up the remaining TAO_Stub reference (that cleanup should not be
- // done here).
- if (this->protocol_proxy_ != 0
- && this->protocol_proxy_->_decr_refcnt () == 1)
+ // Hijack the lock and reference count of the underlying TAO_Stub
+ // object.
+ // @@ There may be a race condition here. We may have to put the
+ // lock back into this class.
+ if (this->protocol_proxy_ != 0)
{
+ TAO_Stub * stub;
+
+ {
+ ACE_GUARD (TAO_SYNCH_MUTEX,
+ mon,
+ this->protocol_proxy_->refcount_lock ());
+
+ CORBA::ULong & refcnt = this->protocol_proxy_->refcount ();
+
+ refcnt--;
+ if (refcnt != 0)
+ return;
+
+ stub = this->protocol_proxy_;
+ this->protocol_proxy_ = 0;
+ }
+
+ stub->destroy ();
delete this;
}
}
@@ -118,7 +135,7 @@ CORBA_Object::_is_a (const char *type_id
//
// XXX if type_id is that of CORBA_Object, "yes, we comply" :-)
- if (this->is_local_)
+ if (this->protocol_proxy_ == 0)
ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0);
if (this->_stubobj ()->type_id.in () != 0
diff --git a/TAO/tao/Stub.h b/TAO/tao/Stub.h
index ad0fdb90550..fd9f434ef13 100644
--- a/TAO/tao/Stub.h
+++ b/TAO/tao/Stub.h
@@ -286,8 +286,33 @@ public:
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException));
+ /// Return a reference to the reference count lock.
+ /**
+ * This method is meant to be used by the CORBA::Object
+ * implementation to allow it to directly manipulate the reference
+ * count.
+ */
+ TAO_SYNCH_MUTEX & refcount_lock (void);
+
+ /// Return number of outstanding references to this object.
+ /**
+ * This method is meant to be used by the CORBA::Object
+ * implementation to allow it to directly manipulate the reference
+ * count.
+ */
+ CORBA::ULong & refcount (void);
+
+ /// Deallocate the TAO_Stub object.
+ /**
+ * This method is intended to be used only by the CORBA::Object
+ * class.
+ */
+ void destroy (void);
+
protected:
- /// Destructor is to be called only through _decr_refcnt().
+
+ /// Destructor is to be called only through _decr_refcnt() to
+ /// enforce proper reference counting.
virtual ~TAO_Stub (void);
private:
diff --git a/TAO/tao/Stub.i b/TAO/tao/Stub.i
index f31ca20cbe5..fb37703ca00 100644
--- a/TAO/tao/Stub.i
+++ b/TAO/tao/Stub.i
@@ -285,6 +285,27 @@ TAO_Stub::servant_orb (CORBA::ORB_ptr orb)
this->servant_orb_ = CORBA::ORB::_duplicate (orb);
}
+ACE_INLINE TAO_SYNCH_MUTEX &
+TAO_Stub::refcount_lock (void)
+{
+ return this->refcount_lock_;
+}
+
+ACE_INLINE CORBA::ULong &
+TAO_Stub::refcount (void)
+{
+ return this->refcount_;
+}
+
+ACE_INLINE void
+TAO_Stub::destroy (void)
+{
+ // The reference count better be zero at this point!
+ delete this;
+}
+
+// ---------------------------------------------------------------
+
// Creator methods for TAO_Stub_Auto_Ptr (TAO_Stub Auto Pointer)
ACE_INLINE
TAO_Stub_Auto_Ptr::TAO_Stub_Auto_Ptr (TAO_Stub *p)