summaryrefslogtreecommitdiff
path: root/TAO/tao/Object.cpp
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/tao/Object.cpp
parent21841fd166725fd06b39ec958e4264a586e0121e (diff)
downloadATCD-daa29310c24eee0428f16fd5e446db40e25898e3.tar.gz
ChangeLogTag:Wed Mar 6 21:55:11 2002 Ossama Othman <ossama@uci.edu>
Diffstat (limited to 'TAO/tao/Object.cpp')
-rw-r--r--TAO/tao/Object.cpp33
1 files changed, 25 insertions, 8 deletions
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