summaryrefslogtreecommitdiff
path: root/TAO/tao
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/tao')
-rw-r--r--TAO/tao/Any.cpp82
-rw-r--r--TAO/tao/Any.h15
-rw-r--r--TAO/tao/Any.i18
-rw-r--r--TAO/tao/CurrentC.cpp4
-rw-r--r--TAO/tao/Exception.cpp39
-rw-r--r--TAO/tao/Exception.h6
-rw-r--r--TAO/tao/IIOP_Object.cpp30
-rw-r--r--TAO/tao/IIOP_Object.h6
-rw-r--r--TAO/tao/IIOP_Object.i4
-rw-r--r--TAO/tao/Makefile48
-rw-r--r--TAO/tao/Marshal.i14
-rw-r--r--TAO/tao/NVList.cpp48
-rw-r--r--TAO/tao/NVList.h21
-rw-r--r--TAO/tao/NVList.i56
-rw-r--r--TAO/tao/ORB.cpp16
-rw-r--r--TAO/tao/ORB.h6
-rw-r--r--TAO/tao/ORB.i33
-rw-r--r--TAO/tao/Object.h4
-rw-r--r--TAO/tao/Object.i14
-rw-r--r--TAO/tao/POAC.cpp37
-rw-r--r--TAO/tao/PolicyC.cpp4
-rw-r--r--TAO/tao/Principal.cpp29
-rw-r--r--TAO/tao/Principal.h18
-rw-r--r--TAO/tao/Principal.i28
-rw-r--r--TAO/tao/Request.cpp29
-rw-r--r--TAO/tao/Request.h9
-rw-r--r--TAO/tao/Request.i27
-rw-r--r--TAO/tao/Server_Request.cpp59
-rw-r--r--TAO/tao/Server_Request.h16
-rw-r--r--TAO/tao/Server_Request.i31
-rw-r--r--TAO/tao/Typecode.cpp89
-rw-r--r--TAO/tao/Typecode.h5
-rw-r--r--TAO/tao/Typecode.i28
-rw-r--r--TAO/tao/Typecode_Constants.cpp64
-rw-r--r--TAO/tao/decode.cpp3
-rw-r--r--TAO/tao/deep_copy.cpp4
36 files changed, 503 insertions, 441 deletions
diff --git a/TAO/tao/Any.cpp b/TAO/tao/Any.cpp
index 5d26fc54892..9788dc5b7ed 100644
--- a/TAO/tao/Any.cpp
+++ b/TAO/tao/Any.cpp
@@ -63,11 +63,10 @@ CORBA_Any::value (void) const
// typecode ...
CORBA_Any::CORBA_Any (void)
- : type_ (CORBA::_tc_null),
+ : type_ (CORBA::TypeCode::_duplicate (CORBA::_tc_null)),
value_ (0),
cdr_ (0),
- any_owns_data_ (CORBA::B_FALSE),
- refcount_ (1)
+ any_owns_data_ (CORBA::B_FALSE)
{
}
@@ -78,13 +77,11 @@ CORBA_Any::CORBA_Any (void)
CORBA_Any::CORBA_Any (CORBA::TypeCode_ptr tc,
void *value,
CORBA::Boolean any_owns_data)
- : type_ (tc),
+ : type_ (CORBA::TypeCode::_duplicate (tc)),
value_ (value),
cdr_ (0),
- any_owns_data_ (any_owns_data),
- refcount_ (1)
+ any_owns_data_ (any_owns_data)
{
- tc->_incr_refcnt ();
// if the Any owns the data, we encode the "value" into a CDR stream and
// store it. We also destroy the "value" since we own it.
if (this->any_owns_data_)
@@ -105,15 +102,16 @@ CORBA_Any::CORBA_Any (CORBA::TypeCode_ptr tc,
// Copy constructor for "Any".
CORBA_Any::CORBA_Any (const CORBA_Any &src)
- : type_ (src.type_ != 0 ? src.type_ : CORBA::_tc_null),
- value_ (0),
+ : value_ (0),
cdr_ (0),
- any_owns_data_ (CORBA::B_TRUE),
- refcount_ (1)
+ any_owns_data_ (CORBA::B_TRUE)
{
- CORBA::Environment env;
+ if (src.type_ != 0)
+ this->type_ = CORBA::TypeCode::_duplicate (src.type_);
+ else
+ this->type_ = CORBA::TypeCode::_duplicate (CORBA::_tc_null);
- this->type_->_incr_refcnt ();
+ CORBA::Environment env;
// does the source own its data? If not, then it is not in the message block
// form and must be encoded. Else we must simply duplicate the message block
@@ -143,7 +141,6 @@ CORBA_Any::operator= (const CORBA_Any &src)
// check if it is a self assignment
if (this == &src)
{
- this->_incr_refcnt ();
return *this;
}
@@ -163,19 +160,20 @@ CORBA_Any::operator= (const CORBA_Any &src)
// seems to depend on the actual data type. Until we fix
// this I'm afraid we will have to leave with a memory leak
// (coryan).
- // delete this->value_;
+ // delete this->value_;
}
- if (this->type_)
- this->type_->_decr_refcnt ();
+ if (this->type_ != 0)
+ CORBA::release (this->type_);
}
// Now copy the contents of the source to ourselves.
- this->type_ = (src.type_) != 0 ? src.type_ : CORBA::_tc_null;
- this->type_->_incr_refcnt ();
+ if (src.type_ != 0)
+ this->type_ = CORBA::TypeCode::_duplicate (src.type_);
+ else
+ this->type_ = CORBA::TypeCode::_duplicate (CORBA::_tc_null);
this->value_ = 0;
this->any_owns_data_ = CORBA::B_TRUE;
- this->refcount_ = 1;
// does the source own its data? If not, then it is not in the message block
// form and must be encoded. Else we must simply duplicate the message block
@@ -196,17 +194,9 @@ CORBA_Any::operator= (const CORBA_Any &src)
// Destructor for an "Any" deep-frees memory if needed.
//
-// NOTE that the assertion below will fire on application programmer
-// errors, such as using _incr/_decr_refcnt out of sync with the true
-// lifetime of an Any value allocated on the stack. BUT it involves
-// changing the refcounting policy so that it's initialized to zero,
-// not one ... which policy affects the whole source base, and not
-// just this data type. Get to this later.
CORBA_Any::~CORBA_Any (void)
{
- // assert (this->refcount_ == 0);
-
// decrement the refcount on the Message_Block we hold, it does not
// matter if we own the data or not, because we always own the
// message block (i.e. it is always cloned or duplicated.
@@ -224,13 +214,13 @@ CORBA_Any::~CORBA_Any (void)
// seems to depend on the actual data type. Until we fix
// this I'm afraid we will have to leave with a memory leak
// (coryan).
- // delete this->value_;
+ // delete this->value_;
this->value_ = 0;
}
}
if (this->type_)
- this->type_->_decr_refcnt ();
+ CORBA::release (this->type_);
}
@@ -242,10 +232,6 @@ CORBA_Any::replace (CORBA::TypeCode_ptr tc,
CORBA::Boolean any_owns_data,
CORBA::Environment &env)
{
- // we may be replacing ourselves. So before releasing our typecode, we
- // increment the refcount of the one that will be assigned to us.
- tc->_incr_refcnt ();
-
// decrement the refcount on the Message_Block we hold, it does not
// matter if we own the data or not, because we always own the
// message block (i.e. it is always cloned or duplicated.
@@ -260,16 +246,16 @@ CORBA_Any::replace (CORBA::TypeCode_ptr tc,
// seems to depend on the actual data type. Until we fix
// this I'm afraid we will have to leave with a memory leak
// (coryan).
- // delete this->value_;
+ // delete this->value_;
}
}
// release our current typecode
if (this->type_ != 0)
- this->type_->_decr_refcnt ();
+ CORBA::release (this->type_);
// assign new typecode
- this->type_ = tc;
+ this->type_ = CORBA::TypeCode::_duplicate (tc);
this->value_ = (void *) value;
this->any_owns_data_ = any_owns_data;
this->cdr_ = 0;
@@ -629,26 +615,6 @@ CORBA_Any::operator>>= (to_object obj) const
return CORBA::B_FALSE;
}
-CORBA::ULong
-CORBA_Any::_incr_refcnt (void)
-{
- return ++refcount_;
-}
-
-CORBA::ULong
-CORBA_Any::_decr_refcnt (void)
-{
- {
- ACE_ASSERT (this != 0);
-
- if (--refcount_ != 0)
- return refcount_;
- }
-
- delete this;
- return 0;
-}
-
// ----------------------------------------------------------------------
// Any_var type
// ----------------------------------------------------------------------
@@ -670,7 +636,7 @@ CORBA::Any_var &
CORBA_Any_var::operator= (const CORBA::Any_var& r)
{
if (this->ptr_ != 0)
- delete (this->ptr_);
+ delete this->ptr_;
this->ptr_ = new CORBA::Any (*r.ptr_);
return *this;
diff --git a/TAO/tao/Any.h b/TAO/tao/Any.h
index 43e7627962a..11b60e43443 100644
--- a/TAO/tao/Any.h
+++ b/TAO/tao/Any.h
@@ -231,16 +231,6 @@ public:
CORBA::Boolean operator>>= (to_object) const;
// extract an object reference
- // = ALLOCATION
- void *operator new (size_t, const void *p);
- // Placement new.
-
- void *operator new (size_t s);
- // Default new.
-
- void operator delete (void *p);
- // Default delete
-
// the following are unsafe operations
// ORBOS/90-01-11, pg 672: For C++ mapping using the CORBA::Environment
// parameter, two forms of the replace method are provided.
@@ -267,11 +257,6 @@ public:
// otherwise. TAO does *not* guarantee that this value may be casted
// to the contained type safely.
- // = Memory management methods.
-
- CORBA::ULong _incr_refcnt (void);
- CORBA::ULong _decr_refcnt (void);
-
// = Debugging method.
static void dump (const CORBA::Any any_value);
diff --git a/TAO/tao/Any.i b/TAO/tao/Any.i
index 20164c32810..dd16c760705 100644
--- a/TAO/tao/Any.i
+++ b/TAO/tao/Any.i
@@ -1,24 +1,6 @@
// $Id$
// This may look like C, but it's really -*- C++ -*-
-ACE_INLINE void *
-CORBA_Any::operator new (size_t, const void *p)
-{
- return (void *) p;
-}
-
-ACE_INLINE void *
-CORBA_Any::operator new (size_t s)
-{
- return ::operator new (s);
-}
-
-ACE_INLINE void
-CORBA_Any::operator delete (void *p)
-{
- ::operator delete (p);
-}
-
// Insertion from special types.
ACE_INLINE void
diff --git a/TAO/tao/CurrentC.cpp b/TAO/tao/CurrentC.cpp
index 0860b6a260b..2105885d690 100644
--- a/TAO/tao/CurrentC.cpp
+++ b/TAO/tao/CurrentC.cpp
@@ -35,7 +35,9 @@ CORBA_Current_ptr CORBA_Current::_narrow (
|| obj->_servant()->_downcast ("IDL:CORBA/Current:1.0") == 0
)
{
- CORBA_Current_ptr new_obj = new CORBA_Current(obj->_stubobj ());
+ STUB_Object *stub = obj->_stubobj ();
+ stub->_incr_refcnt ();
+ CORBA_Current_ptr new_obj = new CORBA_Current(stub);
return new_obj;
} // end of if
STUB_Object *stub = obj->_servant ()->_create_stub (env);
diff --git a/TAO/tao/Exception.cpp b/TAO/tao/Exception.cpp
index 4d5451aaa09..9ad6651681a 100644
--- a/TAO/tao/Exception.cpp
+++ b/TAO/tao/Exception.cpp
@@ -64,20 +64,16 @@ CORBA_Exception::operator new (size_t s)
}
CORBA_Exception::CORBA_Exception (CORBA::TypeCode_ptr tc)
- : type_ (tc),
+ : type_ (CORBA::TypeCode::_duplicate (tc)),
refcount_ (0)
{
- if (this->type_)
- this->type_->_incr_refcnt ();
assert (this->type_ != 0);
}
CORBA_Exception::CORBA_Exception (const CORBA_Exception &src)
- : type_ (src.type_),
+ : type_ (CORBA::TypeCode::_duplicate (src.type_)),
refcount_ (0)
{
- if (this->type_)
- this->type_->_incr_refcnt ();
assert (this->type_ != 0);
}
@@ -95,10 +91,8 @@ CORBA_Exception &
CORBA_Exception::operator = (const CORBA_Exception &src)
{
if (this->type_)
- this->type_->_decr_refcnt ();
- this->type_ = src.type_;
- if (this->type_)
- this->type_->_incr_refcnt ();
+ CORBA::release (this->type_);
+ this->type_ = CORBA::TypeCode::_duplicate (src.type_);
assert (this->type_ != 0);
return *this;
@@ -130,18 +124,23 @@ CORBA_Exception::_is_a (const char* repository_id) const
CORBA::ULong
CORBA_Exception::_incr_refcnt (void)
{
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->refcount_lock_, 0);
return ++this->refcount_;
}
CORBA::ULong
CORBA_Exception::_decr_refcnt (void)
{
- this->refcount_--;
- if (this->refcount_ != 0)
- return this->refcount_;
+ {
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->refcount_lock_, 0);
+ this->refcount_--;
+ if (this->refcount_ != 0)
+ return this->refcount_;
+
+ // release the lock before destroying the object.
+ }
delete this;
-
return 0;
}
@@ -160,10 +159,8 @@ CORBA_UserException &
CORBA_UserException::operator = (const CORBA_UserException &src)
{
if (this->type_)
- this->type_->_decr_refcnt ();
- this->type_ = src.type_;
- if (this->type_)
- this->type_->_incr_refcnt ();
+ CORBA::release (this->type_);
+ this->type_ = CORBA::TypeCode::_duplicate (src.type_);
assert (this->type_ != 0);
return *this;
@@ -209,10 +206,8 @@ CORBA_SystemException &
CORBA_SystemException::operator = (const CORBA_SystemException &src)
{
if (this->type_)
- this->type_->_decr_refcnt ();
- this->type_ = src.type_;
- if (this->type_)
- this->type_->_incr_refcnt ();
+ CORBA::release (this->type_);
+ this->type_ = CORBA::TypeCode::_duplicate (src.type_);
this->minor_ = src.minor_;
this->completed_ = src.completed_;
diff --git a/TAO/tao/Exception.h b/TAO/tao/Exception.h
index f1f14629f7f..88b5fd2d0ab 100644
--- a/TAO/tao/Exception.h
+++ b/TAO/tao/Exception.h
@@ -76,6 +76,12 @@ protected:
private:
CORBA::ULong refcount_;
// Reference count to avoid copying overhead.
+
+ ACE_SYNCH_MUTEX refcount_lock_;
+ // Mutex to protect the reference count; though in most cases this
+ // class is used only in one thread adding a mutex here is *not*
+ // expensive, because uses of this class are never on the critical
+ // path.
};
class TAO_Export CORBA_UserException : public CORBA_Exception
diff --git a/TAO/tao/IIOP_Object.cpp b/TAO/tao/IIOP_Object.cpp
index 005cfdbaa13..61a92af4561 100644
--- a/TAO/tao/IIOP_Object.cpp
+++ b/TAO/tao/IIOP_Object.cpp
@@ -308,20 +308,18 @@ IIOP_Object::is_equivalent (CORBA::Object_ptr other_obj,
CORBA::ULong
IIOP_Object::_incr_refcnt (void)
{
- ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->IUnknown_lock_, 0));
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->refcount_lock_, 0);
- return ++this->refcount_;
+ return this->refcount_++;
}
CORBA::ULong
IIOP_Object::_decr_refcnt (void)
{
{
- ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, mon, this->IUnknown_lock_, 0));
-
- ACE_ASSERT (this != 0);
-
- if (--this->refcount_ > 0)
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, mon, this->refcount_lock_, 0);
+ this->refcount_--;
+ if (this->refcount_ != 0)
return this->refcount_;
}
@@ -720,18 +718,15 @@ IIOP_Object::do_dynamic_call (const char *opname,
if (!(flags & CORBA::OUT_LIST_MEMORY))
{
- CORBA::TypeCode_ptr tcp;
- size_t size;
-
- tcp = result->value ()->type ();
- size = tcp->size (env);
+ CORBA::TypeCode_ptr tcp =
+ CORBA::TypeCode::_duplicate (result->value ()->type ());
+ size_t size = tcp->size (env);
dexc (env, "do_dynamic_call, get result size");
if (size != 0)
{
void *ptr = new CORBA::Octet [size];
- tcp->_incr_refcnt ();
result->value ()->replace (tcp, ptr,
CORBA::B_TRUE, env);
dexc (env, "do_dynamic_call, set result mem");
@@ -792,18 +787,15 @@ IIOP_Object::do_dynamic_call (const char *opname,
// memory for this parameter ...
if (!(flags & CORBA::OUT_LIST_MEMORY))
{
- CORBA::TypeCode_ptr tcp;
- size_t size;
-
- tcp = value->value ()->type ();
- size = tcp->size (env);
+ CORBA::TypeCode_ptr tcp =
+ CORBA::TypeCode::_duplicate (value->value ()->type ());
+ size_t size = tcp->size (env);
dexc (env, "do_dynamic_call, get param size");
if (size != 0)
{
CORBA::Octet *ptr = new CORBA::Octet [size];
- tcp->_incr_refcnt ();
value->value ()->replace (tcp, ptr,
CORBA::B_TRUE, env);
dexc (env, "do_dynamic_call, set result mem");
diff --git a/TAO/tao/IIOP_Object.h b/TAO/tao/IIOP_Object.h
index e0c36286cfa..4962bd5e6ba 100644
--- a/TAO/tao/IIOP_Object.h
+++ b/TAO/tao/IIOP_Object.h
@@ -250,10 +250,10 @@ private:
ACE_Lock* fwd_profile_lock_ptr_;
// Mutex to protect access to the forwarding profile
- ACE_SYNCH_MUTEX IUnknown_lock_;
- // Mutex to protect <IUnknown>-related stuff.
+ ACE_SYNCH_MUTEX refcount_lock_;
+ // Mutex to protect reference count
- u_int refcount_;
+ CORBA::ULong refcount_;
// Number of outstanding references to this object.
CORBA::Boolean use_locate_request_;
diff --git a/TAO/tao/IIOP_Object.i b/TAO/tao/IIOP_Object.i
index 4ba84e667d1..94b23e985c7 100644
--- a/TAO/tao/IIOP_Object.i
+++ b/TAO/tao/IIOP_Object.i
@@ -46,7 +46,7 @@ ACE_INLINE
IIOP_Object::IIOP_Object (char *repository_id)
: STUB_Object (repository_id),
fwd_profile_ (0),
- refcount_ (0),
+ refcount_ (1),
use_locate_request_ (CORBA::B_FALSE),
first_locate_request_ (CORBA::B_FALSE)
{
@@ -61,7 +61,7 @@ IIOP_Object::IIOP_Object (char *repository_id,
: STUB_Object (repository_id),
profile (a_profile),
fwd_profile_ (0),
- refcount_ (0),
+ refcount_ (1),
use_locate_request_ (CORBA::B_FALSE),
first_locate_request_ (CORBA::B_FALSE)
{
diff --git a/TAO/tao/Makefile b/TAO/tao/Makefile
index a43c5abd34c..97f5d0530f7 100644
--- a/TAO/tao/Makefile
+++ b/TAO/tao/Makefile
@@ -293,6 +293,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -514,6 +515,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -735,6 +737,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -956,6 +959,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -1178,6 +1182,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -1399,6 +1404,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -1620,6 +1626,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -1841,6 +1848,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -2069,6 +2077,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -2296,6 +2305,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -2517,6 +2527,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -2738,6 +2749,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -2959,6 +2971,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -3180,6 +3193,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -3401,6 +3415,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -3622,6 +3637,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -3843,6 +3859,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -4066,6 +4083,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -4287,6 +4305,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -4508,6 +4527,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -4729,6 +4749,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -4950,6 +4971,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -5171,6 +5193,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -5394,6 +5417,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -5615,6 +5639,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -5836,6 +5861,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -6057,6 +6083,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -6278,6 +6305,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -6500,6 +6528,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -6721,6 +6750,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -6941,6 +6971,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -7162,6 +7193,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -7383,6 +7415,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -7606,6 +7639,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -7829,6 +7863,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -8052,6 +8087,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -8273,6 +8309,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -8494,6 +8531,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -8718,6 +8756,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -8939,6 +8978,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -9160,6 +9200,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -9392,6 +9433,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -9613,6 +9655,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -9834,6 +9877,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -10057,6 +10101,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -10279,6 +10324,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -10500,6 +10546,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
@@ -10721,6 +10768,7 @@ endif # cxvx86
$(TAO_ROOT)/tao/NVList.h \
$(TAO_ROOT)/tao/NVList.i \
$(TAO_ROOT)/tao/Principal.h \
+ $(TAO_ROOT)/tao/Principal.i \
$(TAO_ROOT)/tao/Request.h \
$(TAO_ROOT)/tao/Request.i \
$(TAO_ROOT)/tao/Stub.h \
diff --git a/TAO/tao/Marshal.i b/TAO/tao/Marshal.i
index 431cc47fd9b..51c13ac242b 100644
--- a/TAO/tao/Marshal.i
+++ b/TAO/tao/Marshal.i
@@ -163,7 +163,8 @@ TAO_Marshal_Any::deep_copy (CORBA::TypeCode_ptr,
const void *dest,
CORBA::Environment &)
{
- (void) new (dest) CORBA::Any (*(CORBA::Any *) source);
+ void* target = ACE_const_cast(void*,dest);
+ (void) new (target) CORBA::Any (*(CORBA::Any *) source);
return CORBA::TypeCode::TRAVERSE_CONTINUE;
}
@@ -174,12 +175,12 @@ TAO_Marshal_TypeCode::deep_copy (CORBA::TypeCode_ptr,
const void *dest,
CORBA::Environment &)
{
- if ((*(CORBA::TypeCode_ptr *) source) != 0)
- dest = source;
+ CORBA::TypeCode_ptr src = *(CORBA::TypeCode_ptr *) source;
+ if (!CORBA::is_nil (src))
+ dest = CORBA::TypeCode::_duplicate (src);
else
- dest = CORBA::_tc_null;
+ dest = CORBA::TypeCode::_duplicate (CORBA::_tc_null);
- ((CORBA::TypeCode_ptr) dest)->_incr_refcnt ();
return CORBA::TypeCode::TRAVERSE_CONTINUE;
}
@@ -237,8 +238,7 @@ TAO_Marshal_TypeCode::deep_free (CORBA::TypeCode_ptr,
const void *,
CORBA::Environment &)
{
- if ((*(CORBA::TypeCode_ptr *) source) != 0)
- (*(CORBA::TypeCode_ptr *) source)->_decr_refcnt ();
+ CORBA::release (*(CORBA::TypeCode_ptr *) source);
return CORBA::TypeCode::TRAVERSE_CONTINUE;
}
diff --git a/TAO/tao/NVList.cpp b/TAO/tao/NVList.cpp
index 6d0ed1e942d..6add0651dd3 100644
--- a/TAO/tao/NVList.cpp
+++ b/TAO/tao/NVList.cpp
@@ -8,9 +8,12 @@
# include "tao/NVList.i"
#endif /* ! __ACE_INLINE__ */
+// Reference counting for DII Request object
+
CORBA::ULong
CORBA_NamedValue::_incr_refcnt (void)
{
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->refcount_lock_, 0);
return this->refcount_++;
}
@@ -18,9 +21,9 @@ CORBA::ULong
CORBA_NamedValue::_decr_refcnt (void)
{
{
- ACE_ASSERT (this != 0);
-
- if (--this->refcount_ != 0)
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->refcount_lock_, 0);
+ this->refcount_--;
+ if (this->refcount_ != 0)
return this->refcount_;
}
@@ -28,21 +31,6 @@ CORBA_NamedValue::_decr_refcnt (void)
return 0;
}
-// Reference counting for DII Request object
-
-void
-CORBA::release (CORBA::NamedValue_ptr nv)
-{
- if (nv)
- nv->_decr_refcnt ();
-}
-
-CORBA::Boolean
-CORBA::is_nil (CORBA::NamedValue_ptr nv)
-{
- return (CORBA::Boolean) (nv == 0);
-}
-
CORBA_NamedValue::~CORBA_NamedValue (void)
{
if (this->name_)
@@ -53,11 +41,12 @@ CORBA_NamedValue::~CORBA_NamedValue (void)
// the any will be destroyed by itself
}
-// =Methods on class NVList
+// ****************************************************************
CORBA::ULong
CORBA_NVList::_incr_refcnt (void)
{
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->refcount_lock_, 0);
return this->refcount_++;
}
@@ -65,9 +54,9 @@ CORBA::ULong
CORBA_NVList::_decr_refcnt (void)
{
{
- ACE_ASSERT (this != 0);
-
- if (--this->refcount_ != 0)
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->refcount_lock_, 0);
+ this->refcount_--;
+ if (this->refcount_ != 0)
return this->refcount_;
}
@@ -75,21 +64,6 @@ CORBA_NVList::_decr_refcnt (void)
return 0;
}
-// Reference counting for DII Request object
-
-void
-CORBA::release (CORBA::NVList_ptr nvl)
-{
- if (nvl)
- nvl->_decr_refcnt ();
-}
-
-CORBA::Boolean
-CORBA::is_nil (CORBA::NVList_ptr nvl)
-{
- return (CORBA::Boolean) (nvl == 0);
-}
-
CORBA_NVList::~CORBA_NVList (void)
{
// initialize an iterator and delete each NamedValue
diff --git a/TAO/tao/NVList.h b/TAO/tao/NVList.h
index 87fe6fb211d..d6b6073839c 100644
--- a/TAO/tao/NVList.h
+++ b/TAO/tao/NVList.h
@@ -43,14 +43,20 @@ public:
~CORBA_NamedValue (void);
// destructor - manages the name and value
- // = Methods required for COM IUnknown support.
+ // The pseudo object static methods..
+ static CORBA_NamedValue* _duplicate (CORBA_NamedValue*);
+ static CORBA_NamedValue* _nil (void);
+ // = Reference counting.
CORBA::ULong _incr_refcnt (void);
CORBA::ULong _decr_refcnt (void);
private:
- u_int refcount_;
- // refcount used in release
+ CORBA::ULong refcount_;
+ // maintains how many references exist to this object
+
+ ACE_SYNCH_MUTEX refcount_lock_;
+ // Protects the reference count.
CORBA::Any any_;
// holds the value
@@ -122,13 +128,15 @@ public:
CORBA::NamedValue_ptr item (CORBA::ULong n, CORBA::Environment &env);
// retrieve the item at the nth location. Raises Bounds
-
// CORBA::Status
void remove (CORBA::ULong n, CORBA::Environment &env);
// remove element at index n. Raises Bounds
- // = Methods required for COM IUnknown support
+ // The pseudo object static methods..
+ static CORBA_NVList* _duplicate (CORBA_NVList*);
+ static CORBA_NVList* _nil (void);
+ // = Reference counting.
CORBA::ULong _incr_refcnt (void);
CORBA::ULong _decr_refcnt (void);
@@ -150,6 +158,9 @@ private:
CORBA::ULong refcount_;
// maintains how many references exist to this object
+ ACE_SYNCH_MUTEX refcount_lock_;
+ // Protects the reference count.
+
friend class CORBA_ORB;
friend class CORBA_Request;
};
diff --git a/TAO/tao/NVList.i b/TAO/tao/NVList.i
index 5cd2155bc2e..f7794e5c8fc 100644
--- a/TAO/tao/NVList.i
+++ b/TAO/tao/NVList.i
@@ -31,6 +31,34 @@ CORBA_NamedValue::flags (void) const
return this->flags_;
}
+ACE_INLINE void
+CORBA::release (CORBA::NamedValue_ptr nv)
+{
+ if (nv)
+ nv->_decr_refcnt ();
+}
+
+ACE_INLINE CORBA::Boolean
+CORBA::is_nil (CORBA::NamedValue_ptr nv)
+{
+ return nv == 0;
+}
+
+ACE_INLINE CORBA_NamedValue*
+CORBA_NamedValue::_duplicate (CORBA_NamedValue *x)
+{
+ if (x != 0)
+ x->_incr_refcnt ();
+ return x;
+}
+
+ACE_INLINE CORBA_NamedValue*
+CORBA_NamedValue::_nil (void)
+{
+ return 0;
+}
+
+// ****************************************************************
// = methods for the NVList class
@@ -47,3 +75,31 @@ CORBA_NVList::count (void) const
{
return this->max_;
}
+
+ACE_INLINE void
+CORBA::release (CORBA::NVList_ptr nvl)
+{
+ if (nvl)
+ nvl->_decr_refcnt ();
+}
+
+ACE_INLINE CORBA::Boolean
+CORBA::is_nil (CORBA::NVList_ptr nvl)
+{
+ return (CORBA::Boolean) (nvl == 0);
+}
+
+ACE_INLINE CORBA_NVList*
+CORBA_NVList::_duplicate (CORBA_NVList *x)
+{
+ if (x != 0)
+ x->_incr_refcnt ();
+ return x;
+}
+
+ACE_INLINE CORBA_NVList*
+CORBA_NVList::_nil (void)
+{
+ return 0;
+}
+
diff --git a/TAO/tao/ORB.cpp b/TAO/tao/ORB.cpp
index e088ff312b5..59efe62540e 100644
--- a/TAO/tao/ORB.cpp
+++ b/TAO/tao/ORB.cpp
@@ -176,22 +176,6 @@ CORBA_ORB::shutdown (CORBA::Boolean /* wait_for_completion */)
return;
}
-CORBA::ULong
-CORBA_ORB::_decr_refcnt (void)
-{
- {
- ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, mon, this->lock_, 0));
-
- ACE_ASSERT (this != 0);
-
- if (--refcount_ != 0)
- return this->refcount_;
- }
-
- delete this;
- return 0;
-}
-
void
CORBA_ORB::create_list (CORBA::Long count,
CORBA::NVList_ptr &retval)
diff --git a/TAO/tao/ORB.h b/TAO/tao/ORB.h
index 749b40ec3cf..3981ca91c63 100644
--- a/TAO/tao/ORB.h
+++ b/TAO/tao/ORB.h
@@ -911,8 +911,6 @@ public:
// provide some more of the CORBA support. Implementations of this
// "CORBA::ORB" class must know how to create stringify/destringify
// their objrefs, as well as how to marshal and unmarshal them.
- virtual CORBA::ULong _incr_refcnt (void);
- virtual CORBA::ULong _decr_refcnt (void);
int open (void);
// Set up the ORB Core's acceptor to listen on the
@@ -927,6 +925,10 @@ public:
// indicates if we have reached a point where all ORB owned resources will be
// deallocated
+ // Reference counting...
+ virtual CORBA::ULong _incr_refcnt (void);
+ virtual CORBA::ULong _decr_refcnt (void);
+
TAO_Leader_Follower_Info &leader_follower_info (void);
// get access to the leader_follower_info
diff --git a/TAO/tao/ORB.i b/TAO/tao/ORB.i
index 68391fe1b39..c429e0881e4 100644
--- a/TAO/tao/ORB.i
+++ b/TAO/tao/ORB.i
@@ -155,13 +155,6 @@ CORBA::wstring_dup (const WChar *const str)
// CORBA dup/release build on top of COM's (why not).
-ACE_INLINE void
-CORBA::release (CORBA::ORB_ptr obj)
-{
- if (obj)
- obj->_decr_refcnt ();
-}
-
// ---------------------------------------------------------------------------
// ORB specific
// ---------------------------------------------------------------------------
@@ -169,9 +162,22 @@ CORBA::release (CORBA::ORB_ptr obj)
ACE_INLINE CORBA::ULong
CORBA_ORB::_incr_refcnt (void)
{
- ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, lock_, 0));
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, lock_, 0);
+ return ++this->refcount_;
+}
- return refcount_++;
+ACE_INLINE CORBA::ULong
+CORBA_ORB::_decr_refcnt (void)
+{
+ {
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, mon, this->lock_, 0);
+ this->refcount_--;
+ if (this->refcount_ != 0)
+ return this->refcount_;
+ }
+
+ delete this;
+ return 0;
}
ACE_INLINE CORBA::ORB_ptr
@@ -182,6 +188,13 @@ CORBA_ORB::_duplicate (CORBA::ORB_ptr obj)
return obj;
}
+ACE_INLINE void
+CORBA::release (CORBA::ORB_ptr obj)
+{
+ if (obj)
+ obj->_decr_refcnt ();
+}
+
// Null pointers represent nil objects.
ACE_INLINE CORBA::ORB_ptr
@@ -193,7 +206,7 @@ CORBA_ORB::_nil (void)
ACE_INLINE CORBA::Boolean
CORBA::is_nil (CORBA::ORB_ptr obj)
{
- return (CORBA::Boolean) (obj == 0);
+ return obj == 0;
}
ACE_INLINE CORBA::Boolean
diff --git a/TAO/tao/Object.h b/TAO/tao/Object.h
index 0185adbabfd..58ae31182f0 100644
--- a/TAO/tao/Object.h
+++ b/TAO/tao/Object.h
@@ -146,6 +146,10 @@ private:
CORBA::ULong refcount_;
// Number of outstanding references to this object.
+ ACE_SYNCH_MUTEX refcount_lock_;
+ // Protect the reference count, this is OK because we do no
+ // duplicates or releases on the critical path.
+
// = Unimplemented methods
CORBA_Object (const CORBA_Object &);
CORBA_Object &operator = (const CORBA_Object &);
diff --git a/TAO/tao/Object.i b/TAO/tao/Object.i
index db51f7d3b0c..84a18d095ff 100644
--- a/TAO/tao/Object.i
+++ b/TAO/tao/Object.i
@@ -5,14 +5,20 @@
ACE_INLINE CORBA::ULong
CORBA_Object::_incr_refcnt (void)
{
- return ++this->refcount_;
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->refcount_lock_, 0);
+ return this->refcount_++;
}
ACE_INLINE CORBA::ULong
CORBA_Object::_decr_refcnt (void)
{
- if (--this->refcount_ != 0)
- return this->refcount_;
+ {
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, mon, this->refcount_lock_, 0);
+ this->refcount_--;
+ if (this->refcount_ != 0)
+ return this->refcount_;
+ }
+
delete this;
return 0;
}
@@ -36,7 +42,7 @@ CORBA_Object::_nil (void)
ACE_INLINE CORBA::Boolean
CORBA::is_nil (CORBA::Object_ptr obj)
{
- return (CORBA::Boolean) (obj == 0);
+ return obj == 0;
}
ACE_INLINE STUB_Object *
diff --git a/TAO/tao/POAC.cpp b/TAO/tao/POAC.cpp
index 1673145bba1..4d277308d11 100644
--- a/TAO/tao/POAC.cpp
+++ b/TAO/tao/POAC.cpp
@@ -183,7 +183,9 @@ PortableServer::ThreadPolicy_ptr PortableServer::ThreadPolicy::_narrow (
return PortableServer::ThreadPolicy::_nil ();
if (!obj->_is_collocated () || !obj->_servant())
{
- PortableServer::ThreadPolicy_ptr new_obj = new PortableServer::ThreadPolicy (obj->_stubobj ()); // construct obj ref using the stub object
+ STUB_Object *stub = obj->_stubobj ();
+ stub->_incr_refcnt ();
+ PortableServer::ThreadPolicy_ptr new_obj = new PortableServer::ThreadPolicy(stub);
return new_obj;
} // end of if
@@ -267,7 +269,9 @@ PortableServer::LifespanPolicy_ptr PortableServer::LifespanPolicy::_narrow (
return PortableServer::LifespanPolicy::_nil ();
if (!obj->_is_collocated () || !obj->_servant())
{
- PortableServer::LifespanPolicy_ptr new_obj = new PortableServer::LifespanPolicy (obj->_stubobj ()); // construct obj ref using the stub object
+ STUB_Object *stub = obj->_stubobj ();
+ stub->_incr_refcnt ();
+ PortableServer::LifespanPolicy_ptr new_obj = new PortableServer::LifespanPolicy (stub);
return new_obj;
} // end of if
@@ -350,7 +354,9 @@ PortableServer::IdUniquenessPolicy_ptr PortableServer::IdUniquenessPolicy::_narr
return PortableServer::IdUniquenessPolicy::_nil ();
if (!obj->_is_collocated () || !obj->_servant())
{
- PortableServer::IdUniquenessPolicy_ptr new_obj = new PortableServer::IdUniquenessPolicy (obj->_stubobj ()); // construct obj ref using the stub object
+ STUB_Object *stub = obj->_stubobj ();
+ stub->_incr_refcnt ();
+ PortableServer::IdUniquenessPolicy_ptr new_obj = new PortableServer::IdUniquenessPolicy (stub);
return new_obj;
} // end of if
@@ -433,7 +439,9 @@ PortableServer::IdAssignmentPolicy_ptr PortableServer::IdAssignmentPolicy::_narr
return PortableServer::IdAssignmentPolicy::_nil ();
if (!obj->_is_collocated () || !obj->_servant())
{
- PortableServer::IdAssignmentPolicy_ptr new_obj = new PortableServer::IdAssignmentPolicy (obj->_stubobj ()); // construct obj ref using the stub object
+ STUB_Object *stub = obj->_stubobj ();
+ stub->_incr_refcnt ();
+ PortableServer::IdAssignmentPolicy_ptr new_obj = new PortableServer::IdAssignmentPolicy (stub);
return new_obj;
} // end of if
@@ -516,7 +524,9 @@ PortableServer::ImplicitActivationPolicy_ptr PortableServer::ImplicitActivationP
return PortableServer::ImplicitActivationPolicy::_nil ();
if (!obj->_is_collocated () || !obj->_servant())
{
- PortableServer::ImplicitActivationPolicy_ptr new_obj = new PortableServer::ImplicitActivationPolicy (obj->_stubobj ()); // construct obj ref using the stub object
+ STUB_Object *stub = obj->_stubobj ();
+ stub->_incr_refcnt ();
+ PortableServer::ImplicitActivationPolicy_ptr new_obj = new PortableServer::ImplicitActivationPolicy (stub);
return new_obj;
} // end of if
@@ -599,7 +609,9 @@ PortableServer::ServantRetentionPolicy_ptr PortableServer::ServantRetentionPolic
return PortableServer::ServantRetentionPolicy::_nil ();
if (!obj->_is_collocated () || !obj->_servant())
{
- PortableServer::ServantRetentionPolicy_ptr new_obj = new PortableServer::ServantRetentionPolicy (obj->_stubobj ()); // construct obj ref using the stub object
+ STUB_Object *stub = obj->_stubobj ();
+ stub->_incr_refcnt ();
+ PortableServer::ServantRetentionPolicy_ptr new_obj = new PortableServer::ServantRetentionPolicy (stub);
return new_obj;
} // end of if
@@ -683,8 +695,10 @@ PortableServer::RequestProcessingPolicy_ptr PortableServer::RequestProcessingPol
return PortableServer::RequestProcessingPolicy::_nil ();
if (!obj->_is_collocated () || !obj->_servant())
{
+ STUB_Object *stub = obj->_stubobj ();
+ stub->_incr_refcnt ();
PortableServer::RequestProcessingPolicy_ptr
- new_obj = new PortableServer::RequestProcessingPolicy (obj->_stubobj ()); // construct obj ref using the stub object
+ new_obj = new PortableServer::RequestProcessingPolicy (stub);
return new_obj;
} // end of if
@@ -773,8 +787,10 @@ PortableServer::SynchronizationPolicy_ptr PortableServer::SynchronizationPolicy:
return PortableServer::SynchronizationPolicy::_nil ();
if (!obj->_is_collocated () || !obj->_servant())
{
+ STUB_Object *stub = obj->_stubobj ();
+ stub->_incr_refcnt ();
PortableServer::SynchronizationPolicy_ptr
- new_obj = new PortableServer::SynchronizationPolicy (obj->_stubobj ()); // construct obj ref using the stub object
+ new_obj = new PortableServer::SynchronizationPolicy (stub);
return new_obj;
} // end of if
@@ -2229,8 +2245,9 @@ PortableServer::Current_ptr PortableServer::Current::_narrow (
return PortableServer::Current::_nil ();
if (!obj->_is_collocated () || !obj->_servant())
{
- PortableServer::Current_ptr
- new_obj = new PortableServer::Current (obj->_stubobj ()); // construct obj ref using the stub object
+ STUB_Object *stub = obj->_stubobj ();
+ stub->_incr_refcnt ();
+ PortableServer::Current_ptr new_obj = new PortableServer::Current(stub);
return new_obj;
} // end of if
diff --git a/TAO/tao/PolicyC.cpp b/TAO/tao/PolicyC.cpp
index 4f7afb9596f..ff5ac91cbcb 100644
--- a/TAO/tao/PolicyC.cpp
+++ b/TAO/tao/PolicyC.cpp
@@ -37,7 +37,9 @@ CORBA_Policy_ptr CORBA_Policy::_narrow (
|| obj->_servant()->_downcast ("IDL:CORBA/Policy:1.0") == 0
)
{
- CORBA_Policy_ptr new_obj = new CORBA_Policy(obj->_stubobj ());
+ STUB_Object *stub = obj->_stubobj ();
+ stub->_incr_refcnt ();
+ CORBA_Policy_ptr new_obj = new CORBA_Policy(stub);
return new_obj;
} // end of if
STUB_Object *stub = obj->_servant ()->_create_stub (env);
diff --git a/TAO/tao/Principal.cpp b/TAO/tao/Principal.cpp
index 87d2b4532e3..47963d9f6d4 100644
--- a/TAO/tao/Principal.cpp
+++ b/TAO/tao/Principal.cpp
@@ -10,46 +10,33 @@
#include "tao/Principal.i"
#endif /* __ACE_INLINE__ */
-void
-CORBA::release (CORBA::Principal_ptr principal)
-{
- if (principal)
- principal->_decr_refcnt ();
-}
-
-CORBA::Boolean
-CORBA::is_nil (CORBA::Principal_ptr principal)
-{
- return (CORBA::Boolean) (principal == 0);
-}
-
CORBA_Principal::CORBA_Principal (void)
{
}
-CORBA_Principal::~CORBA_Principal (void)
-{
- assert (refcount_ == 0);
-}
-
CORBA::ULong
CORBA_Principal::_incr_refcnt (void)
{
- return ++refcount_;
+ return this->refcount_++;
}
CORBA::ULong
CORBA_Principal::_decr_refcnt (void)
{
{
- if (--refcount_ != 0)
- return refcount_;
+ this->refcount_--;
+ if (this->refcount_ != 0)
+ return this->refcount_;
}
delete this;
return 0;
}
+CORBA_Principal::~CORBA_Principal (void)
+{
+}
+
TAO_OutputCDR&
operator<< (TAO_OutputCDR& cdr, CORBA_Principal* x)
{
diff --git a/TAO/tao/Principal.h b/TAO/tao/Principal.h
index b2ddda02264..655c2f1f1f5 100644
--- a/TAO/tao/Principal.h
+++ b/TAO/tao/Principal.h
@@ -35,6 +35,10 @@ public:
// @@ add "==", "<", ">" operators
+ // The pseudo object operations.
+ static CORBA_Principal* _duplicate (CORBA_Principal*);
+ static CORBA_Principal* _nil (void);
+
// = Stuff required for memory management.
CORBA::ULong _incr_refcnt (void);
CORBA::ULong _decr_refcnt (void);
@@ -42,14 +46,20 @@ public:
CORBA_Principal (void);
private:
- CORBA::ULong refcount_;
-
~CORBA_Principal (void);
// = these are not provided
CORBA_Principal &operator = (const CORBA::Principal_ptr &);
CORBA_Principal (const CORBA::Principal_ptr &);
+private:
+ CORBA::ULong refcount_;
+ // Number of outstanding references to this object.
+
+ ACE_SYNCH_MUTEX refcount_mutex_;
+ // Protect the reference count, this is OK because we do no
+ // duplicates or releases on the critical path.
+
#if defined (__GNUG__)
// G++ (even 2.6.3) stupidly thinks instances can't be created.
// This de-warns.
@@ -63,4 +73,8 @@ operator<<(TAO_OutputCDR&, CORBA_Principal*);
extern TAO_Export TAO_InputCDR&
operator>>(TAO_InputCDR&, CORBA_Principal*&);
+#if defined (__ACE_INLINE__)
+# include "tao/Principal.i"
+#endif /* __ACE_INLINE__ */
+
#endif /* TAO_PRINCIPAL_H */
diff --git a/TAO/tao/Principal.i b/TAO/tao/Principal.i
index 74e88caa0c5..68f4d95fa8e 100644
--- a/TAO/tao/Principal.i
+++ b/TAO/tao/Principal.i
@@ -1,2 +1,30 @@
// $Id$
+ACE_INLINE void
+CORBA::release (CORBA::Principal_ptr principal)
+{
+ if (principal)
+ principal->_decr_refcnt ();
+}
+
+ACE_INLINE CORBA::Boolean
+CORBA::is_nil (CORBA::Principal_ptr principal)
+{
+ return (CORBA::Boolean) (principal == 0);
+}
+
+ACE_INLINE CORBA_Principal*
+CORBA_Principal::_duplicate (CORBA_Principal* x)
+{
+ if (x != 0)
+ x->_incr_refcnt ();
+ return x;
+}
+
+
+ACE_INLINE CORBA_Principal*
+CORBA_Principal::_nil (void)
+{
+ return 0;
+}
+
diff --git a/TAO/tao/Request.cpp b/TAO/tao/Request.cpp
index c2cda20144b..315106fd983 100644
--- a/TAO/tao/Request.cpp
+++ b/TAO/tao/Request.cpp
@@ -9,16 +9,19 @@
CORBA::ULong
CORBA_Request::_incr_refcnt (void)
{
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->refcount_lock_, 0);
return refcount_++;
}
CORBA::ULong
CORBA_Request::_decr_refcnt (void)
{
- ACE_ASSERT (this != 0);
-
- if (--refcount_ != 0)
- return refcount_;
+ {
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->refcount_lock_, 0);
+ this->refcount_--;
+ if (this->refcount_ != 0)
+ return this->refcount_;
+ }
delete this;
return 0;
@@ -26,20 +29,6 @@ CORBA_Request::_decr_refcnt (void)
// Reference counting for DII Request object
-void
-CORBA::release (CORBA::Request_ptr req)
-{
- if (req)
- req->_decr_refcnt ();
-}
-
-CORBA::Boolean
-CORBA::is_nil (CORBA::Request_ptr req)
-{
- return (CORBA::Boolean) (req == 0);
-}
-
-
// DII Request class implementation
CORBA_Request::CORBA_Request (CORBA::Object_ptr obj,
@@ -90,7 +79,6 @@ void
CORBA_Request::invoke (void)
{
STUB_Object *stub = this->target_->_stubobj ();
- stub->_incr_refcnt ();
stub->do_dynamic_call ((char *) opname_,
CORBA::B_TRUE,
@@ -99,14 +87,12 @@ CORBA_Request::invoke (void)
flags_,
exceptions_,
env_);
- stub->_decr_refcnt ();
}
void
CORBA_Request::send_oneway (void)
{
STUB_Object *stub = this->target_->_stubobj ();
- stub->_incr_refcnt ();
stub->do_dynamic_call ((char *) opname_,
CORBA::B_FALSE,
@@ -115,5 +101,4 @@ CORBA_Request::send_oneway (void)
flags_,
exceptions_,
env_);
- stub->_decr_refcnt ();
}
diff --git a/TAO/tao/Request.h b/TAO/tao/Request.h
index 4bd7e9a2fcd..8493018c983 100644
--- a/TAO/tao/Request.h
+++ b/TAO/tao/Request.h
@@ -57,7 +57,11 @@ public:
void send_oneway (void);
// Send a oneway request.
- // = Required for COM IUnknown support
+ // Pseudo object methods
+ static CORBA_Request* _duplicate (CORBA_Request*);
+ static CORBA_Request* _nil (void);
+
+ // = Reference counting.
CORBA::ULong _incr_refcnt (void);
CORBA::ULong _decr_refcnt (void);
@@ -100,6 +104,9 @@ private:
CORBA::ULong refcount_;
// reference counting
+
+ ACE_SYNCH_MUTEX refcount_lock_;
+ // protect the reference count
};
#if defined (__ACE_INLINE__)
diff --git a/TAO/tao/Request.i b/TAO/tao/Request.i
index 2209c228421..410a8eb9d0f 100644
--- a/TAO/tao/Request.i
+++ b/TAO/tao/Request.i
@@ -4,6 +4,33 @@
// Return the target of this request.
+ACE_INLINE void
+CORBA::release (CORBA::Request_ptr req)
+{
+ if (req)
+ req->_decr_refcnt ();
+}
+
+ACE_INLINE CORBA::Boolean
+CORBA::is_nil (CORBA::Request_ptr req)
+{
+ return (CORBA::Boolean) (req == 0);
+}
+
+ACE_INLINE CORBA_Request*
+CORBA_Request::_duplicate (CORBA_Request* x)
+{
+ if (x != 0)
+ x->_incr_refcnt ();
+ return x;
+}
+
+ACE_INLINE CORBA_Request*
+CORBA_Request::_nil (void)
+{
+ return 0;
+}
+
ACE_INLINE CORBA::Object_ptr
CORBA_Request::target (void) const
{
diff --git a/TAO/tao/Server_Request.cpp b/TAO/tao/Server_Request.cpp
index 5eafc817e13..fe7121c03c0 100644
--- a/TAO/tao/Server_Request.cpp
+++ b/TAO/tao/Server_Request.cpp
@@ -32,23 +32,6 @@ ACE_TIMEPROBE_EVENT_DESCRIPTIONS (TAO_Server_Request_Timeprobe_Description,
#endif /* ACE_ENABLE_TIMEPROBES */
-CORBA_ServerRequest *
-CORBA_ServerRequest::_duplicate (CORBA_ServerRequest *req)
-{
- if (req)
- {
- req->_incr_refcnt ();
- return req;
- }
- return (CORBA_ServerRequest *) 0;
-}
-
-CORBA_ServerRequest *
-CORBA_ServerRequest::_nil (void)
-{
- return (CORBA_ServerRequest *) 0;
-}
-
IIOP_ServerRequest::IIOP_ServerRequest (TAO_InputCDR &input,
TAO_OutputCDR &output,
CORBA::ORB_ptr the_orb,
@@ -62,7 +45,6 @@ IIOP_ServerRequest::IIOP_ServerRequest (TAO_InputCDR &input,
retval_ (0),
exception_ (0),
exception_type_ (TAO_GIOP_NO_EXCEPTION),
- refcount_ (1),
orb_ (the_orb),
poa_ (the_poa),
service_info_ (),
@@ -155,7 +137,6 @@ IIOP_ServerRequest::IIOP_ServerRequest (CORBA::ULong &request_id,
retval_ (0),
exception_ (0),
exception_type_ (TAO_GIOP_NO_EXCEPTION),
- refcount_ (1),
orb_ (the_orb),
poa_ (the_poa),
service_info_ (0),
@@ -175,25 +156,9 @@ IIOP_ServerRequest::~IIOP_ServerRequest (void)
delete this->retval_;
if (this->exception_)
delete this->exception_;
-}
-
-CORBA::ULong
-IIOP_ServerRequest::_incr_refcnt (void)
-{
- ACE_ASSERT (this->refcount_ > 0);
- return this->refcount_++;
-}
-
-CORBA::ULong
-IIOP_ServerRequest::_decr_refcnt (void)
-{
- ACE_ASSERT (this != 0);
-
- if (--this->refcount_ != 0)
- return this->refcount_;
-
- delete this;
- return 0;
+#if defined (TAO_COPY_OPNAME)
+ CORBA::string_free (this->operation_);
+#endif
}
// Unmarshal in/inout params, and set up to marshal the appropriate
@@ -229,9 +194,7 @@ IIOP_ServerRequest::arguments (CORBA::NVList_ptr &list,
// This is exactly what the TAO IDL compiler generated skeletons do.
CORBA::Any_ptr any = nv->value ();
- CORBA::TypeCode_ptr tc = any->type ();
-
- tc->_incr_refcnt ();
+ CORBA::TypeCode_ptr tc = CORBA::TypeCode::_duplicate (any->type ());
void *value;
if (!any->value ())
@@ -247,15 +210,15 @@ IIOP_ServerRequest::arguments (CORBA::NVList_ptr &list,
// Decrement the refcount of "tc".
//
- // The earlier _incr_refcnt is needed since Any::replace ()
- // releases the typecode inside the Any. Without the dup,
- // the reference count can go to zero, and the typecode
- // would then be deleted.
+ // The earlier TypeCode::_duplicate is needed since
+ // Any::replace () releases the typecode inside the Any.
+ // Without the dup, the reference count can go to zero, and
+ // the typecode would then be deleted.
//
- // This _decr_refcnt ensures that the reference count is
- // correct so the typecode can be deleted some other time.
+ // This _release that the reference count is correct so the
+ // typecode can be deleted some other time.
- tc->_decr_refcnt ();
+ CORBA::release (tc);
}
else
value = (void *)any->value (); // memory was already preallocated
diff --git a/TAO/tao/Server_Request.h b/TAO/tao/Server_Request.h
index 3eaae7c400d..c44166b5d4a 100644
--- a/TAO/tao/Server_Request.h
+++ b/TAO/tao/Server_Request.h
@@ -174,10 +174,6 @@ public:
virtual CORBA::Boolean response_expected (void) const = 0;
// is the response expected
-
- // = Stuff required for memory management.
- virtual CORBA::ULong _incr_refcnt (void) = 0;
- virtual CORBA::ULong _decr_refcnt (void) = 0;
};
class TAO_Export IIOP_ServerRequest : public CORBA_ServerRequest
@@ -270,9 +266,10 @@ public:
virtual const TAO_GIOP_ServiceContextList &service_info (void) const;
- // = Stuff required for memory management.
- virtual CORBA::ULong _incr_refcnt (void);
- virtual CORBA::ULong _decr_refcnt (void);
+ // The pseudo object methods, not really needed because the class is
+ // not in the spec, but we add them for the sake of completeness.
+ static IIOP_ServerRequest* _duplicate (IIOP_ServerRequest*);
+ static IIOP_ServerRequest* _nil (void);
// To handle System Exceptions at the lowest level,
// a method returning the request_id_ is needed.
@@ -317,14 +314,11 @@ private:
CORBA::ULong exception_type_;
// exception type (will be NO_EXCEPTION in the majority of the cases)
- CORBA::ULong refcount_;
- // Number of things hold references to here.
-
CORBA::ORB_ptr orb_;
// The ORB with which this server request is associated.
TAO_POA *poa_;
- // The object adapter with whicih this server request is associated.
+ // The object adapter with which this server request is associated.
TAO_GIOP_ServiceContextList service_info_;
// The service context for the request (CORBA Reference?)
diff --git a/TAO/tao/Server_Request.i b/TAO/tao/Server_Request.i
index d625019dda8..9bd790115fc 100644
--- a/TAO/tao/Server_Request.i
+++ b/TAO/tao/Server_Request.i
@@ -1,10 +1,35 @@
// $Id$
+ACE_INLINE CORBA::Boolean
+CORBA::is_nil (CORBA_ServerRequest *x)
+{
+ return x != 0;
+}
+
+// @@ TODO TAO allocates its ServerRequest objects from the stack,
+// using reference counting wouldn't help much. Using a _clone()
+// method would make the following methods really easy to implement,
+// but that's hard to implement for the extremely optimized
+// IIOP_ServerRequest.
+// Another solution would be to modify the class hierarchy, make
+// ServerRequest the "slow" version (with copies for each field) and
+// IIOP_ServerRequest the "fast" version (with no copies at all). The
+// first would be use for DII and the later for SII.
+ACE_INLINE CORBA_ServerRequest *
+CORBA_ServerRequest::_duplicate (CORBA_ServerRequest *)
+{
+ return 0;
+}
+
ACE_INLINE void
-CORBA::release (CORBA_ServerRequest *req)
+CORBA::release (CORBA_ServerRequest *)
+{
+}
+
+ACE_INLINE CORBA_ServerRequest *
+CORBA_ServerRequest::_nil (void)
{
- if (req)
- req->_decr_refcnt ();
+ return 0;
}
ACE_INLINE TAO_InputCDR &
diff --git a/TAO/tao/Typecode.cpp b/TAO/tao/Typecode.cpp
index 642798a1040..44f47f70b2d 100644
--- a/TAO/tao/Typecode.cpp
+++ b/TAO/tao/Typecode.cpp
@@ -18,21 +18,6 @@
# include "tao/Typecode.i"
#endif /* ! __ACE_INLINE__ */
-// CORBA compliant duplicate
-CORBA::TypeCode_ptr
-CORBA_TypeCode::_duplicate (CORBA::TypeCode_ptr tc)
-{
- if (tc)
- tc->_incr_refcnt ();
- return tc;
-}
-
-CORBA::TypeCode_ptr
-CORBA::TypeCode::_nil (void)
-{
- return (CORBA::TypeCode_ptr)0;
-}
-
CORBA_TypeCode::Bounds::Bounds (void)
: CORBA_UserException (CORBA::_tc_Bounds)
{
@@ -43,6 +28,8 @@ CORBA_TypeCode::BadKind::BadKind (void)
{
}
+// decreases the refcount and deletes when refcount reaches 0
+
// Constructor for CONSTANT typecodes with empty parameter lists.
// These are only created once, and those constants are shared.
@@ -206,20 +193,6 @@ CORBA_TypeCode::~CORBA_TypeCode (void)
}
}
-// decreases the refcount and deletes when refcount reaches 0
-
-void CORBA::release (CORBA::TypeCode_ptr tc)
-{
- if (tc)
- tc->_decr_refcnt ();
-}
-
-// returns true if the typecode is NULL
-CORBA::Boolean CORBA::is_nil (CORBA::TypeCode_ptr tc)
-{
- return (CORBA::Boolean) (tc == 0);
-}
-
// Return the i-th member typecode if it exists, else raise an
// exception. Possible exceptions are BadKind and Bounds.
//
@@ -462,9 +435,15 @@ TC_Private_State::TC_Private_State (CORBA::TCKind kind)
// and the subtree we hold.
TC_Private_State::~TC_Private_State (void)
{
- // the following two just point into the buffer. So we just make it point to NUL
+ // the following just point into the buffer. So we just make it
+ // point to 0
this->tc_id_ = 0;
- this->tc_name_ = 0;
+
+ if (this->tc_name_ != 0)
+ {
+ CORBA::string_free (this->tc_name_);
+ this->tc_name_ = 0;
+ }
// determine what kind of children we may have and free the space accordingly
switch (this->tc_kind_)
@@ -587,41 +566,21 @@ TC_Private_State::~TC_Private_State (void)
CORBA::ULong
CORBA_TypeCode::_incr_refcnt (void)
{
- assert (this != 0);
-
- if (this->orb_owns_)
- return this->refcount_; // this better be 1
- else if (parent_)
- // we are owned by the parent
- // return parent_->Addref ();
- return this->refcount_; // 1
- else
- return this->refcount_++;
+ return this->refcount_++;
}
CORBA::ULong
CORBA_TypeCode::_decr_refcnt (void)
{
- ACE_ASSERT (this != 0);
-
- u_long result;
-
- if (this->orb_owns_)
- result = this->refcount_; // 1
- else if (this->parent_)
- // return parent_->_decr_refcnt ();
- result = this->refcount_; // 1
- else
- {
- result = --this->refcount_;
-
- if (result == 0)
- delete this;
-
- return result;
- }
-
- return result;
+ {
+ this->refcount_--;
+ if (this->refcount_ != 0)
+ return this->refcount_;
+ }
+ // @@ TODO This is an intentional memory leak to discover other
+ // problems..
+ delete this;
+ return 0;
}
// check if typecodes are equal. Equality is based on a mix of structural and
@@ -2226,7 +2185,7 @@ CORBA_TypeCode::typecode_param (CORBA::ULong n,
else if (!stream.read_ulong (temp) // default used
|| !stream.read_ulong (temp)) // member count
{
- tc->_decr_refcnt ();
+ CORBA::release (tc);
env.exception (new CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO));
return 0;
}
@@ -2246,7 +2205,7 @@ CORBA_TypeCode::typecode_param (CORBA::ULong n,
|| !stream.skip_string () // member name
|| !skip_typecode (stream))
{ // member typecode
- tc->_decr_refcnt ();
+ CORBA::release (tc);
env.exception (new CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO));
return 0;
}
@@ -2257,11 +2216,11 @@ CORBA_TypeCode::typecode_param (CORBA::ULong n,
env) != CORBA::TypeCode::TRAVERSE_CONTINUE
|| !stream.skip_string ()) // member name
{
- tc->_decr_refcnt ();
+ CORBA::release (tc);
env.exception (new CORBA::BAD_TYPECODE (CORBA::COMPLETED_NO));
return 0;
}
- tc->_decr_refcnt ();
+ CORBA::release (tc);
if (stream.decode (CORBA::_tc_TypeCode,
&tc, this,
diff --git a/TAO/tao/Typecode.h b/TAO/tao/Typecode.h
index 457b7c87781..c7669701fda 100644
--- a/TAO/tao/Typecode.h
+++ b/TAO/tao/Typecode.h
@@ -170,8 +170,9 @@ public:
// returns the alignment requirements for this typecode. used by the
// IIOP marshaling engine.
- CORBA::ULong _incr_refcnt (void);
- CORBA::ULong _decr_refcnt (void);
+ // Reference counting operations.
+ CORBA::ULong _incr_refcnt (void);
+ CORBA::ULong _decr_refcnt (void);
// = Following three are deprecated
diff --git a/TAO/tao/Typecode.i b/TAO/tao/Typecode.i
index 888b8ee5b62..5212888ada8 100644
--- a/TAO/tao/Typecode.i
+++ b/TAO/tao/Typecode.i
@@ -1,5 +1,33 @@
// $Id$
+ACE_INLINE void
+CORBA::release (CORBA::TypeCode_ptr tc)
+{
+ if (tc)
+ tc->_decr_refcnt ();
+}
+
+// returns true if the typecode is NULL
+ACE_INLINE CORBA::Boolean
+CORBA::is_nil (CORBA::TypeCode_ptr tc)
+{
+ return tc == 0;
+}
+
+ACE_INLINE CORBA::TypeCode_ptr
+CORBA_TypeCode::_duplicate (CORBA::TypeCode_ptr tc)
+{
+ if (tc)
+ tc->_incr_refcnt ();
+ return tc;
+}
+
+ACE_INLINE CORBA::TypeCode_ptr
+CORBA::TypeCode::_nil (void)
+{
+ return (CORBA::TypeCode_ptr)0;
+}
+
ACE_INLINE CORBA::TCKind
CORBA_TypeCode::kind (CORBA::Environment &env) const
{
diff --git a/TAO/tao/Typecode_Constants.cpp b/TAO/tao/Typecode_Constants.cpp
index 347567e991f..3da0ea7da2c 100644
--- a/TAO/tao/Typecode_Constants.cpp
+++ b/TAO/tao/Typecode_Constants.cpp
@@ -428,83 +428,83 @@ TAO_TypeCodes::fini (void)
// Initialize all the standard typecodes owned by the ORB
// Null and void
- delete CORBA::_tc_null;
+ CORBA::release (CORBA::_tc_null);
- delete CORBA::_tc_void;
+ CORBA::release (CORBA::_tc_void);
// Basic numeric types: short, long, longlong, and unsigned variants
- delete CORBA::_tc_short;
+ CORBA::release (CORBA::_tc_short);
- delete CORBA::_tc_long;
+ CORBA::release (CORBA::_tc_long);
- delete CORBA::_tc_longlong;
+ CORBA::release (CORBA::_tc_longlong);
- delete CORBA::_tc_ushort;
+ CORBA::release (CORBA::_tc_ushort);
- delete CORBA::_tc_ulong;
+ CORBA::release (CORBA::_tc_ulong);
- delete CORBA::_tc_ulonglong;
+ CORBA::release (CORBA::_tc_ulonglong);
// Floating point types: single, double, quad precision
- delete CORBA::_tc_float;
+ CORBA::release (CORBA::_tc_float);
- delete CORBA::_tc_double;
+ CORBA::release (CORBA::_tc_double);
- delete CORBA::_tc_longdouble;
+ CORBA::release (CORBA::_tc_longdouble);
// Various simple quantities.
- delete CORBA::_tc_boolean;
+ CORBA::release (CORBA::_tc_boolean);
- delete CORBA::_tc_octet;
+ CORBA::release (CORBA::_tc_octet);
// Internationalization-related data types: ISO Latin/1 and "wide"
// characters, and strings of each. "wchar" is probably Unicode 1.1,
// "wstring" being null-terminated sets thereof.
- delete CORBA::_tc_char;
+ CORBA::release (CORBA::_tc_char);
- delete CORBA::_tc_wchar;
+ CORBA::release (CORBA::_tc_wchar);
// a string/wstring have a simple parameter list that indicates the length
- delete CORBA::_tc_string;
+ CORBA::release (CORBA::_tc_string);
- delete CORBA::_tc_wstring;
+ CORBA::release (CORBA::_tc_wstring);
//
// Various things that can be passed as "general" parameters:
// Any, TypeCode_ptr, Principal_ptr, Object_ptr
//
- delete CORBA::_tc_any;
+ CORBA::release (CORBA::_tc_any);
- delete CORBA::_tc_TypeCode;
+ CORBA::release (CORBA::_tc_TypeCode);
- delete CORBA::_tc_Principal;
+ CORBA::release (CORBA::_tc_Principal);
// typecode for objref is complex, has two string parameters
//
- delete CORBA::_tc_Object;
+ CORBA::release (CORBA::_tc_Object);
// other ORB owned typecodes
- delete CORBA::_tc_Bounds;
+ CORBA::release (CORBA::_tc_Bounds);
- delete CORBA::_tc_BadKind;
+ CORBA::release (CORBA::_tc_BadKind);
// additional typecodes in the CORBA namespace
- delete CORBA::_tc_Policy;
+ CORBA::release (CORBA::_tc_Policy);
- delete CORBA::_tc_PolicyList;
+ CORBA::release (CORBA::_tc_PolicyList);
- delete CORBA::_tc_Current;
+ CORBA::release (CORBA::_tc_Current);
- delete CORBA::_tc_Identifier;
+ CORBA::release (CORBA::_tc_Identifier);
- delete CORBA::_tc_RepositoryId;
+ CORBA::release (CORBA::_tc_RepositoryId);
- delete CORBA::_tc_PolicyType;
+ CORBA::release (CORBA::_tc_PolicyType);
// TAO specific
- delete TC_opaque;
+ CORBA::release (TC_opaque);
- delete TC_ServiceContextList;
+ CORBA::release (TC_ServiceContextList);
- delete TC_completion_status;
+ CORBA::release (TC_completion_status);
}
diff --git a/TAO/tao/decode.cpp b/TAO/tao/decode.cpp
index 290fba2d004..3377da4e171 100644
--- a/TAO/tao/decode.cpp
+++ b/TAO/tao/decode.cpp
@@ -178,7 +178,6 @@ TAO_Marshal_Any::decode (CORBA::TypeCode_ptr,
{
any->any_owns_data_ = 1;
any->value_ = 0;
- elem_tc->_incr_refcnt ();
any->type_ = elem_tc;
// now skip the value
// retval = stream->skip (elem_tc, env);
@@ -694,7 +693,7 @@ TAO_Marshal_ObjRef::decode (CORBA::TypeCode_ptr,
// the corba proxy would have already incremented the reference count on
// the objdata. So we decrement it here by 1 so that the objdata is now
// fully owned by the corba_proxy that was created.
- objdata->_decr_refcnt ();
+ // objdata->_decr_refcnt ();
}
if (retval == CORBA::TypeCode::TRAVERSE_CONTINUE
&& continue_decoding == CORBA::B_TRUE)
diff --git a/TAO/tao/deep_copy.cpp b/TAO/tao/deep_copy.cpp
index ed3d26222dd..1bfc1f1bf64 100644
--- a/TAO/tao/deep_copy.cpp
+++ b/TAO/tao/deep_copy.cpp
@@ -1122,8 +1122,8 @@ TAO_Marshal_Except::deep_copy (CORBA::TypeCode_ptr tc,
// to ensure that memory is appropriately freed and to hold the
// exception ID. We just copy that typecode.
- *(CORBA::TypeCode_ptr *) dest = *(CORBA::TypeCode_ptr *) source;
- (void) (*(CORBA::TypeCode_ptr *) dest)->_incr_refcnt ();
+ *(CORBA::TypeCode_ptr *) dest =
+ CORBA::TypeCode::_duplicate (*(CORBA::TypeCode_ptr *) source);
// compute the number of fields in the struct
int member_count = tc->member_count (env);