summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelliott_c <elliott_c@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2006-07-17 14:42:07 +0000
committerelliott_c <elliott_c@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2006-07-17 14:42:07 +0000
commite16de8c8c2f4d0a6eb44160dc887fe875c83bb7f (patch)
tree8d4caf5c22cd4c69e8a455cb79683d909be7122c
parentb6b6f7e828f346ac0c38b363fafe25f0a8e0532a (diff)
downloadATCD-e16de8c8c2f4d0a6eb44160dc887fe875c83bb7f.tar.gz
ChangeLogTag: Mon Jul 17 14:40:43 UTC 2006 Chad Elliott <elliott_c@ociweb.com>
-rw-r--r--TAO/ChangeLog150
-rw-r--r--TAO/TAO_IDL/be/be_visitor_union/union_cs.cpp1
-rw-r--r--TAO/tao/AnyTypeCode/Any_Impl.h2
-rw-r--r--TAO/tao/AnyTypeCode/NVList.h4
-rw-r--r--TAO/tao/CDR.cpp32
-rw-r--r--TAO/tao/CDR.h12
-rw-r--r--TAO/tao/CSD_Framework/CSD_FW_Server_Request_Wrapper.cpp113
-rw-r--r--TAO/tao/CSD_Framework/CSD_FW_Server_Request_Wrapper.h17
-rw-r--r--TAO/tao/CSD_ThreadPool.mpc1
-rw-r--r--TAO/tao/CSD_ThreadPool/CSD_TP_Collocated_Synch_Request.cpp6
-rw-r--r--TAO/tao/Client_Strategy_Factory.cpp7
-rw-r--r--TAO/tao/Client_Strategy_Factory.h4
-rw-r--r--TAO/tao/Configurable_Refcount.cpp9
-rw-r--r--TAO/tao/Configurable_Refcount.h69
-rw-r--r--TAO/tao/Configurable_Refcount.inl55
-rw-r--r--TAO/tao/Environment.i8
-rw-r--r--TAO/tao/GIOP_Message_Base.cpp91
-rw-r--r--TAO/tao/GIOP_Message_Lite.cpp42
-rw-r--r--TAO/tao/IORTable/Table_Adapter.cpp6
-rw-r--r--TAO/tao/Incoming_Message_Queue.cpp50
-rw-r--r--TAO/tao/Incoming_Message_Queue.h5
-rw-r--r--TAO/tao/Leader_Follower.cpp6
-rw-r--r--TAO/tao/LocalObject.h2
-rw-r--r--TAO/tao/Messaging/AMH_Response_Handler.cpp4
-rw-r--r--TAO/tao/ORB.cpp3
-rw-r--r--TAO/tao/ORB.h6
-rw-r--r--TAO/tao/ORB.i19
-rw-r--r--TAO/tao/ORB_Core.h2
-rw-r--r--TAO/tao/ORB_Core.i10
-rw-r--r--TAO/tao/Object.cpp51
-rw-r--r--TAO/tao/Object.h5
-rw-r--r--TAO/tao/Object.i4
-rw-r--r--TAO/tao/PortableServer/POA_Current_Impl.cpp2
-rw-r--r--TAO/tao/PortableServer/POA_Current_Impl.h8
-rw-r--r--TAO/tao/PortableServer/POA_Current_Impl.inl19
-rw-r--r--TAO/tao/PortableServer/Root_POA.cpp5
-rw-r--r--TAO/tao/PortableServer/Servant_Upcall.cpp2
-rw-r--r--TAO/tao/PortableServer/Servant_Upcall.h1
-rw-r--r--TAO/tao/Principal.h2
-rw-r--r--TAO/tao/Profile.cpp31
-rw-r--r--TAO/tao/Profile.h6
-rw-r--r--TAO/tao/RTCORBA/Thread_Pool.cpp38
-rw-r--r--TAO/tao/Resource_Factory.cpp7
-rw-r--r--TAO/tao/Resource_Factory.h4
-rw-r--r--TAO/tao/Stub.cpp4
-rw-r--r--TAO/tao/Stub.h2
-rw-r--r--TAO/tao/TAO_Server_Request.cpp10
-rw-r--r--TAO/tao/TAO_Server_Request.h12
-rw-r--r--TAO/tao/TAO_Server_Request.i54
-rw-r--r--TAO/tao/TAO_Singleton_Manager.cpp6
-rw-r--r--TAO/tao/Tagged_Profile.cpp5
-rw-r--r--TAO/tao/Tagged_Profile.h4
-rw-r--r--TAO/tao/Tagged_Profile.i6
-rw-r--r--TAO/tao/Valuetype/ValueBase.h2
-rw-r--r--TAO/tao/Var_Size_Argument_T.cpp4
-rw-r--r--TAO/tao/default_client.cpp21
-rw-r--r--TAO/tao/default_client.h1
-rw-r--r--TAO/tao/default_resource.cpp20
-rw-r--r--TAO/tao/default_resource.h1
-rw-r--r--TAO/tao/tao.mpc1
60 files changed, 732 insertions, 342 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index b38ba11687f..a03560785e3 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,153 @@
+Mon Jul 17 14:40:43 UTC 2006 Chad Elliott <elliott_c@ociweb.com>
+
+ * TAO_IDL/be/be_visitor_union/union_cs.cpp:
+
+ The memset of the discriminator was redundant as it is assigned
+ directly after the memset of the union data.
+
+ * tao/CDR.h:
+ * tao/CDR.cpp:
+
+ Added a constructor that takes an ACE_Data_Block* which can be
+ used to avoid an allocation while constructing the
+ ACE_Message_Block held by the ACE_OutputCDR. [RT 8372]
+
+ * tao/CSD_Framework/CSD_FW_Server_Request_Wrapper.h:
+ * tao/CSD_Framework/CSD_FW_Server_Request_Wrapper.cpp:
+
+ Use the new inline TAO_ServerRequest constructor. This avoids
+ having to allocate a costly dummy input and output cdr.
+
+ Avoid using ACE_CString for the operation name which will avoid
+ memory allocations when it isn't necessary. Most of the time, the
+ operation name can be shared from the operation_details_ object.
+
+ When the type of TAO_Tagged_Profile::type_id_ changed in the
+ previous commit, the cloning needed to take that into account.
+ [RT 8372]
+
+ When cloning the operation details, allocate an input cdr with a
+ "large" message block that will be shared by the output cdr as
+ the marshaling of the arguments is done. This allows us to
+ avoid the copying of the data block, in most situations, from the
+ output cdr into the input cdr as was done in the previous version.
+ [RT 8372]
+
+ * tao/CSD_ThreadPool.mpc:
+
+ Added a requires for threads as this project shouldn't be built if
+ thread support is not going to be built into TAO.
+
+ * tao/Client_Strategy_Factory.h:
+ * tao/Client_Strategy_Factory.cpp:
+ * tao/Configurable_Refcount.h:
+ * tao/Configurable_Refcount.inl:
+ * tao/Configurable_Refcount.cpp:
+ * tao/Object.h:
+ * tao/Object.i:
+ * tao/Object.cpp:
+ * tao/Profile.h:
+ * tao/Profile.cpp:
+ * tao/Resource_Factory.h:
+ * tao/Resource_Factory.cpp:
+ * tao/default_client.h:
+ * tao/default_client.cpp:
+ * tao/default_resource.h:
+ * tao/tao.mpc:
+
+ The TAO_Configurable_Refcount can be used as an ACE_Atomic_Op with
+ either a null mutex or a thread mutex. Those classes that use it
+ used to use either a null mutex or a thread mutex and an integer
+ based reference count.
+
+ * tao/GIOP_Message_Base.cpp:
+
+ When processing a request, a character buffer is allocated on the
+ stack. Previously, it was passed as a parameter to the
+ TAO_OutputCDR and an ACE_Data_Block was heap allocated during the
+ construction of the ACE_Message_Block held by the ACE_OutputCDR.
+
+ Now, the ACE_Data_Block is constructed on the stack as well and
+ passed in during the construction of the ACE_Message_Block to
+ avoid heap allocations altogether. [RT 8372]
+
+ * tao/GIOP_Message_Lite.cpp:
+ * tao/Incoming_Message_Queue.h:
+ * tao/Incoming_Message_Queue.cpp:
+
+ Factored various forms of creating a TAO_Queued_Data (with and
+ without an ACE_Message_Block) into a single method. Doing this
+ allows us to avoid extra manipulations of the reference count in
+ the ACE_Data_Block involved.
+
+ * tao/Environment.i:
+ * tao/Leader_Follower.cpp:
+ * tao/TAO_Singleton_Manager.cpp:
+ * tao/Var_Size_Argument_T.cpp:
+ * tao/default_resource.cpp:
+ * tao/IORTable/Table_Adapter.cpp:
+ * tao/CSD_ThreadPool/CSD_TP_Collocated_Synch_Request.cpp:
+ * tao/RTCORBA/Thread_Pool.cpp:
+
+ Replace many instances of the use of a bare 'new' with the
+ equivalent ACE_NEW or ACE_NEW_RETURN macro. [RT 8372]
+
+ * tao/LocalObject.h:
+ * tao/Principal.h:
+ * tao/Stub.h:
+ * tao/Stub.cpp:
+ * tao/AnyTypeCode/Any_Impl.h:
+ * tao/AnyTypeCode/NVList.h:
+ * tao/Messaging/AMH_Response_Handler.cpp:
+ * tao/Valuetype/ValueBase.h:
+
+ Use unsigned long instead of CORBA::ULong to be able to take
+ advantage of the ACE_Atomic_Op<> template specialization.
+ CORBA::ULong doesn't necessarily equate to unsigned long.
+
+ * tao/ORB.h:
+ * tao/ORB.i:
+ * tao/ORB.cpp:
+ * tao/ORB_Core.h:
+ * tao/ORB_Core.i:
+
+ Switch from using a thread mutex and CORBA::ULong to an
+ ACE_Atomic_Op<> with a thread mutex and unsigned long. When the
+ assembler based specialization of ACE_Atomic_Op<> is used, there
+ is a performance benefit.
+
+ * tao/PortableServer/POA_Current_Impl.h:
+ * tao/PortableServer/POA_Current_Impl.inl:
+ * tao/PortableServer/POA_Current_Impl.cpp:
+ * tao/PortableServer/Servant_Upcall.h:
+ * tao/PortableServer/Servant_Upcall.cpp:
+
+ Use an octet sequence array of a specific size (512 bytes by
+ default) when constructing the ObjectId. This allows us to avoid
+ allocations during an upcall in most situations. [RT 8372]
+
+ * tao/PortableServer/Root_POA.cpp:
+
+ Begin the starting_at index at the TAO_OBJECTKEY_PREFIX_SIZE
+ instead of starting it at zero and then adding the value directly
+ after that. This is probably immeasurable performance-wise.
+
+ * tao/TAO_Server_Request.h:
+ * tao/TAO_Server_Request.i:
+ * tao/TAO_Server_Request.cpp:
+
+ Avoid using ACE_CString for the operation name which will avoid
+ memory allocations when it isn't necessary. Most of the time, the
+ operation name can be shared from the operation_details_ object.
+
+ * tao/Tagged_Profile.h:
+ * tao/Tagged_Profile.i:
+ * tao/Tagged_Profile.cpp:
+
+ Avoid using ACE_CString as the type_id_. The type_id_ was never
+ used for anything more than a holder of a char* that it didn't
+ own, but incurred allocation penalties during construction.
+
Mon Jul 17 14:26:08 UTC 2006 Ciju John <john_c@ociweb.com>
* orbsvcs/orbsvcs/Event/ECG_Mcast_EH.cpp:
diff --git a/TAO/TAO_IDL/be/be_visitor_union/union_cs.cpp b/TAO/TAO_IDL/be/be_visitor_union/union_cs.cpp
index 8e8d563605c..3405d6c8fb9 100644
--- a/TAO/TAO_IDL/be/be_visitor_union/union_cs.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_union/union_cs.cpp
@@ -94,7 +94,6 @@ int be_visitor_union_cs::visit_union (be_union *node)
*os << be_nl << be_nl
<< node->name () << "::" << node->local_name () << " (void)" << be_nl
<< "{" << be_idt_nl
- << "ACE_OS::memset (&this->disc_, 0, sizeof (this->disc_));" << be_nl
<< "ACE_OS::memset (&this->u_, 0, sizeof (this->u_));" << be_nl
<< "this->disc_ = ";
diff --git a/TAO/tao/AnyTypeCode/Any_Impl.h b/TAO/tao/AnyTypeCode/Any_Impl.h
index 9eaf83b482d..0e04ce527b5 100644
--- a/TAO/tao/AnyTypeCode/Any_Impl.h
+++ b/TAO/tao/AnyTypeCode/Any_Impl.h
@@ -110,7 +110,7 @@ namespace TAO
private:
/// Reference counter.
- ACE_Atomic_Op<TAO_SYNCH_MUTEX, CORBA::ULong> refcount_;
+ ACE_Atomic_Op<TAO_SYNCH_MUTEX, unsigned long> refcount_;
};
}
diff --git a/TAO/tao/AnyTypeCode/NVList.h b/TAO/tao/AnyTypeCode/NVList.h
index 9e5ca449710..d78a228726a 100644
--- a/TAO/tao/AnyTypeCode/NVList.h
+++ b/TAO/tao/AnyTypeCode/NVList.h
@@ -124,7 +124,7 @@ namespace CORBA
private:
/// Reference counter.
- ACE_Atomic_Op<TAO_SYNCH_MUTEX, ULong> refcount_;
+ ACE_Atomic_Op<TAO_SYNCH_MUTEX, unsigned long> refcount_;
/// holds the value
Any any_;
@@ -286,7 +286,7 @@ namespace CORBA
ULong max_;
/// Reference counter.
- ACE_Atomic_Op<TAO_SYNCH_MUTEX, ULong> refcount_;
+ ACE_Atomic_Op<TAO_SYNCH_MUTEX, unsigned long> refcount_;
/// Protects the incoming pointer.
TAO_SYNCH_MUTEX lock_;
diff --git a/TAO/tao/CDR.cpp b/TAO/tao/CDR.cpp
index 31efb9b0ea6..4ac35f5e957 100644
--- a/TAO/tao/CDR.cpp
+++ b/TAO/tao/CDR.cpp
@@ -28,7 +28,9 @@ static const char *TAO_CDR_Timeprobe_Description[] =
"OutputCDR::ctor[3] - enter",
"OutputCDR::ctor[3] - leave",
"OutputCDR::ctor[4] - enter",
- "OutputCDR::ctor[4] - leave"
+ "OutputCDR::ctor[4] - leave",
+ "OutputCDR::ctor[5] - enter",
+ "OutputCDR::ctor[5] - leave"
};
enum
@@ -40,7 +42,9 @@ enum
TAO_OUTPUT_CDR_CTOR3_ENTER,
TAO_OUTPUT_CDR_CTOR3_LEAVE,
TAO_OUTPUT_CDR_CTOR4_ENTER,
- TAO_OUTPUT_CDR_CTOR4_LEAVE
+ TAO_OUTPUT_CDR_CTOR4_LEAVE,
+ TAO_OUTPUT_CDR_CTOR5_ENTER,
+ TAO_OUTPUT_CDR_CTOR5_LEAVE
};
// Setup Timeprobes
@@ -154,6 +158,29 @@ TAO_OutputCDR::TAO_OutputCDR (ACE_Message_Block *data,
ACE_FUNCTION_TIMEPROBE (TAO_OUTPUT_CDR_CTOR4_ENTER);
}
+TAO_OutputCDR::TAO_OutputCDR (ACE_Data_Block *data_block,
+ int byte_order,
+ ACE_Allocator* message_block_allocator,
+ size_t memcpy_tradeoff,
+ TAO_GIOP_Fragmentation_Strategy * fs,
+ ACE_CDR::Octet major_version,
+ ACE_CDR::Octet minor_version)
+ : ACE_OutputCDR (data_block,
+ byte_order,
+ message_block_allocator,
+ memcpy_tradeoff,
+ major_version,
+ minor_version)
+ , fragmentation_strategy_ (fs)
+ , more_fragments_ (false)
+ , request_id_ (0)
+ , stub_ (0)
+ , message_semantics_ (-1)
+ , timeout_ (0)
+{
+ ACE_FUNCTION_TIMEPROBE (TAO_OUTPUT_CDR_CTOR5_ENTER);
+}
+
void
TAO_OutputCDR::throw_stub_exception (int error_num ACE_ENV_ARG_DECL)
{
@@ -246,7 +273,6 @@ TAO_InputCDR::TAO_InputCDR (const TAO_OutputCDR& rhs,
{
}
-
void
TAO_InputCDR::throw_stub_exception (int error_num ACE_ENV_ARG_DECL)
{
diff --git a/TAO/tao/CDR.h b/TAO/tao/CDR.h
index 3bfb47b2f14..4820a469316 100644
--- a/TAO/tao/CDR.h
+++ b/TAO/tao/CDR.h
@@ -148,6 +148,18 @@ public:
ACE_CDR::Octet minor_version =
TAO_DEF_GIOP_MINOR);
+ /// Build a CDR stream with an initial data block, it will *not* remove
+ /// <data_block>, since it did not allocated it.
+ TAO_OutputCDR (ACE_Data_Block *data,
+ int byte_order = ACE_CDR_BYTE_ORDER,
+ ACE_Allocator* message_block_allocator = 0,
+ size_t memcpy_tradeoff = 0,
+ TAO_GIOP_Fragmentation_Strategy * fs = 0,
+ ACE_CDR::Octet major_version =
+ TAO_DEF_GIOP_MAJOR,
+ ACE_CDR::Octet minor_version =
+ TAO_DEF_GIOP_MINOR);
+
/// Destructor.
~TAO_OutputCDR (void);
diff --git a/TAO/tao/CSD_Framework/CSD_FW_Server_Request_Wrapper.cpp b/TAO/tao/CSD_Framework/CSD_FW_Server_Request_Wrapper.cpp
index 8c2b40d7f28..24684bf7866 100644
--- a/TAO/tao/CSD_Framework/CSD_FW_Server_Request_Wrapper.cpp
+++ b/TAO/tao/CSD_Framework/CSD_FW_Server_Request_Wrapper.cpp
@@ -22,6 +22,11 @@ TAO::CSD::FW_Server_Request_Wrapper::~FW_Server_Request_Wrapper()
// Only delete the request if we cloned it.
if (this->is_clone_)
{
+ // The TAO_Tagged_Profile type_id_ may have been duplicated.
+ if (this->request_->profile_.type_id_ != 0)
+ CORBA::string_free (
+ const_cast<char*> (this->request_->profile_.type_id_));
+
// Since this TAO_ServerRequest object is a clone, it
// "owns" the input and output CDR objects held by the
// incoming_ and outgoing_ data members, respectfully.
@@ -43,7 +48,7 @@ TAO::CSD::FW_Server_Request_Wrapper::~FW_Server_Request_Wrapper()
delete [] opname;
delete this->request_->operation_details_;
}
-
+
if (this->request_->transport_ != 0)
this->request_->transport_->remove_reference ();
@@ -61,7 +66,7 @@ TAO::CSD::FW_Server_Request_Wrapper::dispatch
ACE_TRY
{
servant->_dispatch(*this->request_, 0 ACE_ENV_ARG_PARAMETER);
- ACE_CHECK;
+ ACE_TRY_CHECK;
}
// Only CORBA exceptions are caught here.
ACE_CATCHANY
@@ -148,7 +153,10 @@ TAO_ServerRequest*
TAO::CSD::FW_Server_Request_Wrapper::clone (TAO_ServerRequest*& request)
{
// TBD-CSD: Ultimately add an argument for an allocator.
- TAO_ServerRequest* clone_obj = this->create_new_request ();
+ TAO_ServerRequest* clone_obj;
+ ACE_NEW_RETURN (clone_obj,
+ TAO_ServerRequest (),
+ 0);
if (clone_obj == 0)
{
@@ -159,9 +167,11 @@ TAO::CSD::FW_Server_Request_Wrapper::clone (TAO_ServerRequest*& request)
// ACTION: Assuming that a shallow-copy is ok here.
clone_obj->mesg_base_ = request->mesg_base_;
- // TYPE: ACE_CString
- // ACTION: Assignment performs deep-copy of string contents.
- clone_obj->operation_ = request->operation_;
+ // TYPE: const char*
+ // ACTION: Method performs deep-copy of string contents.
+ clone_obj->operation (CORBA::string_dup (request->operation ()),
+ request->operation_length (),
+ 1);
// TYPE: CORBA::Object_var
// ACTION: Assignment performs reference-counted copy of object ref.
@@ -240,8 +250,8 @@ TAO::CSD::FW_Server_Request_Wrapper::clone (TAO_ServerRequest*& request)
if (request->operation_details_ != 0)
{
ACE_ASSERT (request->incoming_ == 0);
- if (this->clone (request->operation_details_,
- clone_obj->operation_details_,
+ if (this->clone (request->operation_details_,
+ clone_obj->operation_details_,
clone_obj->incoming_) == false)
{
return 0;
@@ -295,17 +305,28 @@ TAO::CSD::FW_Server_Request_Wrapper::clone (TAO_InputCDR*& from)
bool
TAO::CSD::FW_Server_Request_Wrapper::clone (TAO_Operation_Details const *& from,
- TAO_Operation_Details const *& to,
+ TAO_Operation_Details const *& to,
TAO_InputCDR*& cdr)
{
TAO_Operation_Details *& from_non_const
= const_cast <TAO_Operation_Details *&>(from);
- char* cloned_op_name = new char[from_non_const->opname_len_ + 1];
+ char* cloned_op_name;
+ ACE_NEW_RETURN (cloned_op_name,
+ char[from_non_const->opname_len_ + 1],
+ false);
ACE_OS::strncpy(cloned_op_name, from_non_const->opname_, from_non_const->opname_len_);
cloned_op_name[from_non_const->opname_len_] = '\0';
- TAO_OutputCDR outcdr;
+ static const size_t mb_size = 2048;
+ ACE_NEW_RETURN (cdr,
+ TAO_InputCDR (mb_size),
+ false);
+
+ // To avoid duplicating and copying the data block, allow the
+ // TAO_OutputCDR to share the data block of TAO_InputCDR's message block.
+ ACE_Message_Block* mb = const_cast<ACE_Message_Block*> (cdr->start ());
+ TAO_OutputCDR outcdr (mb);
if (! from_non_const->marshal_args (outcdr))
{
@@ -315,10 +336,26 @@ TAO::CSD::FW_Server_Request_Wrapper::clone (TAO_Operation_Details const *& from,
return false;
}
- ACE_NEW_RETURN (cdr,
- TAO_InputCDR (outcdr),
- false);
-
+ // The TAO_OutputCDR made a new message block around the data block
+ // held by the message block owned by the TAO_InputCDR. We need to
+ // make sure that the results of marshaling are propagated back to the
+ // message block in the TAO_InputCDR.
+ const ACE_Message_Block* begin = outcdr.begin ();
+ if (begin == outcdr.current ())
+ {
+ // A chain was not made, so we can just adjust the read and write
+ // pointers
+ mb->rd_ptr (begin->rd_ptr ());
+ mb->wr_ptr (begin->wr_ptr ());
+ }
+ else
+ {
+ // A costly, but necessary, copying of data blocks. This shouldn't
+ // happen that often assuming that the size of the message block
+ // allocated during the allocation of TAO_InputCDR is "big enough"
+ // for most operation parameters.
+ cdr->reset (begin, outcdr.byte_order ());
+ }
// CSD-TBD: Eventually need to use allocators.
@@ -373,7 +410,7 @@ TAO::CSD::FW_Server_Request_Wrapper::clone (TAO_Operation_Details const *& from,
void
-TAO::CSD::FW_Server_Request_Wrapper::clone (TAO_Tagged_Profile& from,
+TAO::CSD::FW_Server_Request_Wrapper::clone (TAO_Tagged_Profile& from,
TAO_Tagged_Profile& to)
{
to.orb_core_ = from.orb_core_;
@@ -382,7 +419,8 @@ TAO::CSD::FW_Server_Request_Wrapper::clone (TAO_Tagged_Profile& from,
to.object_key_ = from.object_key_;
to.profile_ = from.profile_;
to.profile_index_ = from.profile_index_;
- to.type_id_ = from.type_id_;
+ to.type_id_ = from.type_id_ == 0 ? 0 :
+ CORBA::string_dup (from.type_id_);
}
@@ -393,45 +431,16 @@ TAO::CSD::FW_Server_Request_Wrapper::clone (TAO_Service_Context& from,
to.service_context_ = from.service_context_;
}
-TAO_ServerRequest*
-TAO::CSD::FW_Server_Request_Wrapper::create_new_request ()
-{
- // Use one of constructor to create the TAO_ServerRequest object then
- // reset the data members. This reduces the footprint due to a default
- // TAO_ServerRequest constructor.
- //
- //TAO_ServerRequest (TAO_Pluggable_Messaging *mesg_base,
- // TAO_InputCDR &input,
- // TAO_OutputCDR &output,
- // TAO_Transport *transport,
- // TAO_ORB_Core *orb_core);
-
- TAO_ServerRequest* request = 0;
-
- TAO_InputCDR dummy_input ((ACE_Message_Block *)0); // empty input cdr stream
- TAO_OutputCDR dummy_output ((char *)0, (size_t) 0); // empty output cdr stream
- ACE_NEW_RETURN (request,
- TAO_ServerRequest (0,
- dummy_input,
- dummy_output,
- 0,
- 0),
- 0);
-
- request->incoming_ = 0;
- request->outgoing_ = 0;
-
- return request;
-}
-
-
-TAO_OutputCDR*
+TAO_OutputCDR*
TAO::CSD::FW_Server_Request_Wrapper::create_new_output_cdr ()
{
- TAO_OutputCDR* cdr = 0;
+ TAO_OutputCDR* cdr = 0;
// A buffer that we will use to initialise the CDR stream
- char* repbuf = new char[ACE_CDR::DEFAULT_BUFSIZE];
+ char* repbuf;
+ ACE_NEW_RETURN (repbuf,
+ char[ACE_CDR::DEFAULT_BUFSIZE],
+ 0);
ACE_CDR::Octet major;
ACE_CDR::Octet minor;
diff --git a/TAO/tao/CSD_Framework/CSD_FW_Server_Request_Wrapper.h b/TAO/tao/CSD_Framework/CSD_FW_Server_Request_Wrapper.h
index e76b4090487..5268fb8a357 100644
--- a/TAO/tao/CSD_Framework/CSD_FW_Server_Request_Wrapper.h
+++ b/TAO/tao/CSD_Framework/CSD_FW_Server_Request_Wrapper.h
@@ -52,8 +52,8 @@ namespace TAO
* FW_Server_Request_Wrapper class' implementation, and all CSD
* Strategies will work again. It's a maintenance issue.
*
- * @note: The CSD namespace is inside of TAO namespace in current
- * implementation. This can be changed but, at least for now, it's
+ * @note: The CSD namespace is inside of TAO namespace in current
+ * implementation. This can be changed but, at least for now, it's
* already been delivered to some customs, we leave it as-is. If it
* needs to change, we will make this change.
*/
@@ -87,13 +87,13 @@ namespace TAO
TAO_InputCDR* clone (TAO_InputCDR*& from);
/// Create a deep copy of a TAO_Operation_Details object and marshall
- /// the arguments into a TAO_InputCDR stream. The cloned TAO_Operation_Details
- /// object is created without any arguments. This would help the skeleton
- /// code to determine whether the arguments are in the operation_details_
+ /// the arguments into a TAO_InputCDR stream. The cloned TAO_Operation_Details
+ /// object is created without any arguments. This would help the skeleton
+ /// code to determine whether the arguments are in the operation_details_
/// object or should be demarshalled from the incoming_ stream in the request_
/// object.
bool clone (TAO_Operation_Details const *& from,
- TAO_Operation_Details const *& to,
+ TAO_Operation_Details const *& to,
TAO_InputCDR* & cdr);
/// Clone the TAO_Tagged_Profile object.
@@ -102,14 +102,11 @@ namespace TAO
/// Clone the TAO_Service_Context object.
void clone (TAO_Service_Context& from, TAO_Service_Context& to);
- /// Create a new TAO_ServerRequest with default initial values.
- TAO_ServerRequest* create_new_request ();
-
/// Create a TAO_OutputCDR stream initialized with a heap allocated
/// buffer.
TAO_OutputCDR* create_new_output_cdr ();
- /// A flag that indicates that the TAO_ServerRequest object
+ /// A flag that indicates that the TAO_ServerRequest object
/// is already cloned.
bool is_clone_;
diff --git a/TAO/tao/CSD_ThreadPool.mpc b/TAO/tao/CSD_ThreadPool.mpc
index 67be4b9bf00..9181084a3fa 100644
--- a/TAO/tao/CSD_ThreadPool.mpc
+++ b/TAO/tao/CSD_ThreadPool.mpc
@@ -3,6 +3,7 @@ project : csd_framework, core {
sharedname = TAO_CSD_ThreadPool
dynamicflags = TAO_CSD_TP_BUILD_DLL
includes += $(TAO_ROOT)/tao
+ requires += threads
Source_Files {
CSD_ThreadPool
diff --git a/TAO/tao/CSD_ThreadPool/CSD_TP_Collocated_Synch_Request.cpp b/TAO/tao/CSD_ThreadPool/CSD_TP_Collocated_Synch_Request.cpp
index 31c6c32e1a7..c7d7d00fcde 100644
--- a/TAO/tao/CSD_ThreadPool/CSD_TP_Collocated_Synch_Request.cpp
+++ b/TAO/tao/CSD_ThreadPool/CSD_TP_Collocated_Synch_Request.cpp
@@ -36,10 +36,10 @@ TAO::CSD::TP_Collocated_Synch_Request::dispatch_i()
#if defined (TAO_HAS_EXCEPTIONS)
ACE_CATCHALL
{
- this->exception_
- = new CORBA::UNKNOWN (CORBA::SystemException::_tao_minor_code
+ ACE_NEW (this->exception_ ,
+ CORBA::UNKNOWN (CORBA::SystemException::_tao_minor_code
(TAO_UNHANDLED_SERVER_CXX_EXCEPTION, 0),
- CORBA::COMPLETED_MAYBE);
+ CORBA::COMPLETED_MAYBE));
}
#endif
ACE_ENDTRY;
diff --git a/TAO/tao/Client_Strategy_Factory.cpp b/TAO/tao/Client_Strategy_Factory.cpp
index f8cfb870b74..2cc73497870 100644
--- a/TAO/tao/Client_Strategy_Factory.cpp
+++ b/TAO/tao/Client_Strategy_Factory.cpp
@@ -16,6 +16,13 @@ TAO_Client_Strategy_Factory::create_profile_lock (void)
return 0;
}
+TAO_Configurable_Refcount
+TAO_Client_Strategy_Factory::create_profile_refcount (void)
+{
+ return TAO_Configurable_Refcount (
+ TAO_Configurable_Refcount::TAO_NULL_LOCK);
+}
+
TAO_Transport_Mux_Strategy *
TAO_Client_Strategy_Factory::create_transport_mux_strategy (TAO_Transport *)
{
diff --git a/TAO/tao/Client_Strategy_Factory.h b/TAO/tao/Client_Strategy_Factory.h
index 407e580b509..14eb2370c77 100644
--- a/TAO/tao/Client_Strategy_Factory.h
+++ b/TAO/tao/Client_Strategy_Factory.h
@@ -23,6 +23,7 @@
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "tao/Versioned_Namespace.h"
+#include "tao/Configurable_Refcount.h"
#include "ace/Service_Object.h"
@@ -56,6 +57,9 @@ public:
*/
virtual ACE_Lock* create_profile_lock (void);
+ /// Create the refcount for the profile
+ virtual TAO_Configurable_Refcount create_profile_refcount (void);
+
/// Create the correct client request muxing strategy.
virtual TAO_Transport_Mux_Strategy *create_transport_mux_strategy (TAO_Transport *transport);
diff --git a/TAO/tao/Configurable_Refcount.cpp b/TAO/tao/Configurable_Refcount.cpp
new file mode 100644
index 00000000000..44f5f7f6138
--- /dev/null
+++ b/TAO/tao/Configurable_Refcount.cpp
@@ -0,0 +1,9 @@
+#include "Configurable_Refcount.h"
+
+#if !defined (__ACE_INLINE__)
+# include "Configurable_Refcount.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID (tao,
+ Configurable_Refcount,
+ "$Id$")
diff --git a/TAO/tao/Configurable_Refcount.h b/TAO/tao/Configurable_Refcount.h
new file mode 100644
index 00000000000..cf2af53a2ba
--- /dev/null
+++ b/TAO/tao/Configurable_Refcount.h
@@ -0,0 +1,69 @@
+// This may look like C, but it's really
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Configurable_Refcount.h
+ *
+ * $Id$
+ *
+ * Definition for a synchronised refcountable interface.
+ *
+ * @author Fred Kuhns <fredk@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef TAO_CONFIGURABLE_REFCOUNT_H
+#define TAO_CONFIGURABLE_REFCOUNT_H
+
+#include /**/ "ace/pre.h"
+#include "ace/Atomic_Op.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/Null_Mutex.h"
+#include "tao/TAO_Export.h"
+#include "tao/orbconf.h"
+
+TAO_BEGIN_VERSIONED_NAMESPACE_DECL
+
+/**
+ * @class TAO_Configurable_Refcount
+ *
+ * @brief Definition for a synchronised refcountable interface.
+ */
+class TAO_Export TAO_Configurable_Refcount
+{
+public:
+ enum Lock_Type
+ {
+ TAO_NULL_LOCK,
+ TAO_THREAD_LOCK
+ };
+
+ TAO_Configurable_Refcount (Lock_Type type = TAO_THREAD_LOCK,
+ unsigned long value = 1);
+
+ unsigned long increment (void);
+ unsigned long decrement (void);
+
+ unsigned long value (void) const;
+
+private:
+ Lock_Type type_;
+ ACE_Atomic_Op<ACE_SYNCH_NULL_MUTEX, unsigned long> null_refcount_;
+ ACE_Atomic_Op<TAO_SYNCH_MUTEX, unsigned long> mutex_refcount_;
+};
+
+
+TAO_END_VERSIONED_NAMESPACE_DECL
+
+#if defined (__ACE_INLINE__)
+# include "Configurable_Refcount.inl"
+#endif /* __ACE_INLINE__ */
+
+#include /**/ "ace/post.h"
+
+#endif /* TAO_CONFIGURABLE_REFCOUNT */
diff --git a/TAO/tao/Configurable_Refcount.inl b/TAO/tao/Configurable_Refcount.inl
new file mode 100644
index 00000000000..c885976bbc6
--- /dev/null
+++ b/TAO/tao/Configurable_Refcount.inl
@@ -0,0 +1,55 @@
+// -*- C++ -*-
+//$Id$
+
+TAO_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_INLINE
+TAO_Configurable_Refcount::TAO_Configurable_Refcount (
+ TAO_Configurable_Refcount::Lock_Type type,
+ unsigned long value)
+ : type_ (type),
+ null_refcount_ (value),
+ mutex_refcount_ (value)
+{
+}
+
+ACE_INLINE unsigned long
+TAO_Configurable_Refcount::increment (void)
+{
+ switch(this->type_)
+ {
+ case TAO_NULL_LOCK:
+ return this->null_refcount_++;
+ case TAO_THREAD_LOCK:
+ default:
+ return this->mutex_refcount_++;
+ }
+}
+
+ACE_INLINE unsigned long
+TAO_Configurable_Refcount::decrement (void)
+{
+ switch(this->type_)
+ {
+ case TAO_NULL_LOCK:
+ return --this->null_refcount_;
+ case TAO_THREAD_LOCK:
+ default:
+ return --this->mutex_refcount_;
+ }
+}
+
+ACE_INLINE unsigned long
+TAO_Configurable_Refcount::value (void) const
+{
+ switch(this->type_)
+ {
+ case TAO_NULL_LOCK:
+ return this->null_refcount_.value ();
+ case TAO_THREAD_LOCK:
+ default:
+ return this->mutex_refcount_.value ();
+ }
+}
+
+TAO_END_VERSIONED_NAMESPACE_DECL
diff --git a/TAO/tao/Environment.i b/TAO/tao/Environment.i
index 9a710cebffd..a8547215d6d 100644
--- a/TAO/tao/Environment.i
+++ b/TAO/tao/Environment.i
@@ -3,6 +3,8 @@
// $Id$
+#include "ace/OS_Memory.h"
+
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE
@@ -35,7 +37,11 @@ CORBA::Environment::_duplicate (CORBA::Environment *x)
return 0;
}
- return new CORBA::Environment (*x);
+ CORBA::Environment* ptr = 0;
+ ACE_NEW_RETURN (ptr,
+ CORBA::Environment (*x),
+ 0);
+ return ptr;
}
ACE_INLINE
diff --git a/TAO/tao/GIOP_Message_Base.cpp b/TAO/tao/GIOP_Message_Base.cpp
index 242c13c983f..fdc07c0dd59 100644
--- a/TAO/tao/GIOP_Message_Base.cpp
+++ b/TAO/tao/GIOP_Message_Base.cpp
@@ -304,7 +304,9 @@ TAO_GIOP_Message_Base::format_message (TAO_OutputCDR &stream)
ACE_Message_Block* consolidated_block = 0;
if (stream.begin()->cont () != 0)
{
- consolidated_block = new ACE_Message_Block;
+ ACE_NEW_RETURN (consolidated_block,
+ ACE_Message_Block,
+ 0);
ACE_CDR::consolidate (consolidated_block, stream.begin ());
buf = (char *) (consolidated_block->rd_ptr ());
}
@@ -658,12 +660,22 @@ TAO_GIOP_Message_Base::process_request_message (TAO_Transport *transport,
qd->minor_version_,
generator_parser);
- // A buffer that we will use to initialise the CDR stream
+ // A buffer that we will use to initialise the CDR stream. Since we're
+ // allocating the buffer on the stack, we may as well allocate the data
+ // block on the stack too and avoid an allocation inside the message
+ // block of the CDR.
#if defined (ACE_INITIALIZE_MEMORY_BEFORE_USE)
char repbuf[ACE_CDR::DEFAULT_BUFSIZE] = { 0 };
#else
char repbuf[ACE_CDR::DEFAULT_BUFSIZE];
#endif /* ACE_INITIALIZE_MEMORY_BEFORE_USE */
+ ACE_Data_Block out_db (sizeof (repbuf),
+ ACE_Message_Block::MB_DATA,
+ repbuf,
+ this->orb_core_->input_cdr_buffer_allocator (),
+ 0,
+ ACE_Message_Block::DONT_DELETE,
+ this->orb_core_->input_cdr_dblock_allocator ());
// Initialize an output CDR on the stack
// NOTE: Don't jump to a conclusion as to why we are using the
@@ -675,11 +687,8 @@ TAO_GIOP_Message_Base::process_request_message (TAO_Transport *transport,
// lock, we need to set things like this -- put stuff in TSS here
// and transfer to global memory when we get flow controlled. We
// need to work on the message block to get it right!
- TAO_OutputCDR output (repbuf,
- sizeof repbuf,
+ TAO_OutputCDR output (&out_db,
TAO_ENCAP_BYTE_ORDER,
- this->orb_core_->input_cdr_buffer_allocator (),
- this->orb_core_->input_cdr_dblock_allocator (),
this->orb_core_->input_cdr_msgblock_allocator (),
this->orb_core_->orb_params ()->cdr_memcpy_tradeoff (),
this->fragmentation_strategy_.get (),
@@ -1678,24 +1687,6 @@ TAO_GIOP_Message_Base::is_ready_for_bidirectional (TAO_OutputCDR &msg)
TAO_Queued_Data *
TAO_GIOP_Message_Base::make_queued_data (size_t sz)
{
- // Get a node for the queue..
- TAO_Queued_Data *qd =
- TAO_Queued_Data::make_queued_data (
- this->orb_core_->transport_message_buffer_allocator ());
-
- if (qd == 0)
- {
- if (TAO_debug_level > 0)
- {
- ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("TAO (%P|%t) - TAO_GIOP_Message_Base::make_queued_data, ")
- ACE_TEXT ("our of memory, failed to allocate queued data object\n")));
- }
- return 0; // NULL pointer
- }
-
- // @@todo: We have a similar method in Transport.cpp. Need to see how
- // we can factor them out..
// Make a datablock for the size requested + something. The
// "something" is required because we are going to align the data
// block in the message block. During alignment we could loose some
@@ -1705,58 +1696,24 @@ TAO_GIOP_Message_Base::make_queued_data (size_t sz)
this->orb_core_->create_input_cdr_data_block (sz +
ACE_CDR::MAX_ALIGNMENT);
- if (db == 0)
- {
- TAO_Queued_Data::release (qd);
-
- if (TAO_debug_level > 0)
- {
- ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("TAO (%P|%t) - TAO_GIOP_Message_Base::make_queued_data, ")
- ACE_TEXT ("out of memory, failed to allocate input data block of size %u\n"),
- sz));
- }
- return 0; // NULL pointer
- }
-
- ACE_Allocator *alloc =
- this->orb_core_->input_cdr_msgblock_allocator ();
-
- if (alloc == 0)
- {
- if (TAO_debug_level >= 8)
- {
- ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT ("(%P|%t) - TAO_GIOP_Message_Base::make_queued_data,")
- ACE_TEXT (" no ACE_Allocator defined\n")));
- }
- }
-
-
- ACE_Message_Block mb (db,
- 0,
- alloc);
-
- ACE_Message_Block *new_mb = mb.duplicate ();
+ TAO_Queued_Data *qd =
+ TAO_Queued_Data::make_queued_data (
+ this->orb_core_->transport_message_buffer_allocator (),
+ this->orb_core_->input_cdr_msgblock_allocator (),
+ db);
- if (new_mb == 0)
+ if (qd == 0)
{
- TAO_Queued_Data::release (qd);
- db->release();
-
if (TAO_debug_level > 0)
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("TAO (%P|%t) - TAO_GIOP_Message_Base::make_queued_data, ")
- ACE_TEXT ("out of memory, failed to allocate message block\n")));
+ ACE_TEXT ("out of memory, failed to allocate queued data object\n")));
}
- return 0;
+ db->release ();
+ return 0; // NULL pointer
}
- ACE_CDR::mb_align (new_mb);
-
- qd->msg_block_ = new_mb;
-
return qd;
}
diff --git a/TAO/tao/GIOP_Message_Lite.cpp b/TAO/tao/GIOP_Message_Lite.cpp
index a3c30058d59..f980ee907af 100644
--- a/TAO/tao/GIOP_Message_Lite.cpp
+++ b/TAO/tao/GIOP_Message_Lite.cpp
@@ -220,7 +220,9 @@ TAO_GIOP_Message_Lite::format_message (TAO_OutputCDR &stream)
ACE_Message_Block* consolidated_block = 0;
if (stream.begin()->cont() != 0)
{
- consolidated_block = new ACE_Message_Block;
+ ACE_NEW_RETURN (consolidated_block,
+ ACE_Message_Block,
+ 0);
ACE_CDR::consolidate(consolidated_block, stream.begin());
buf = (char *) (consolidated_block->rd_ptr ());
}
@@ -1670,15 +1672,6 @@ TAO_GIOP_Message_Lite::dump_msg (const char *label,
TAO_Queued_Data *
TAO_GIOP_Message_Lite::make_queued_data (size_t sz)
{
- // Get a node for the queue..
- TAO_Queued_Data *qd =
- TAO_Queued_Data::make_queued_data ();
-
- if (qd == 0)
- {
- return 0;
- }
-
// Make a datablock for the size requested + something. The
// "something" is required because we are going to align the data
// block in the message block. During alignment we could loose some
@@ -1688,33 +1681,18 @@ TAO_GIOP_Message_Lite::make_queued_data (size_t sz)
this->orb_core_->create_input_cdr_data_block (sz +
ACE_CDR::MAX_ALIGNMENT);
- if (db == 0)
- {
- TAO_Queued_Data::release (qd);
- return 0;
- }
-
- ACE_Allocator *alloc =
- this->orb_core_->input_cdr_msgblock_allocator ();
-
- ACE_Message_Block mb (db,
- 0,
- alloc);
-
- ACE_Message_Block *new_mb = mb.duplicate ();
+ TAO_Queued_Data *qd =
+ TAO_Queued_Data::make_queued_data (
+ this->orb_core_->transport_message_buffer_allocator (),
+ this->orb_core_->input_cdr_msgblock_allocator (),
+ db);
- if (new_mb == 0)
+ if (qd == 0)
{
- TAO_Queued_Data::release (qd);
- db->release();
-
+ db->release ();
return 0;
}
- ACE_CDR::mb_align (new_mb);
-
- qd->msg_block_ = new_mb;
-
return qd;
}
diff --git a/TAO/tao/IORTable/Table_Adapter.cpp b/TAO/tao/IORTable/Table_Adapter.cpp
index 18e9873d933..bf31f486a7b 100644
--- a/TAO/tao/IORTable/Table_Adapter.cpp
+++ b/TAO/tao/IORTable/Table_Adapter.cpp
@@ -177,7 +177,11 @@ TAO_Table_Adapter_Factory::TAO_Table_Adapter_Factory (void)
TAO_Adapter*
TAO_Table_Adapter_Factory::create (TAO_ORB_Core *oc)
{
- return new TAO_Table_Adapter (oc);
+ TAO_Adapter* ptr = 0;
+ ACE_NEW_RETURN (ptr,
+ TAO_Table_Adapter (oc),
+ 0);
+ return ptr;
}
TAO_END_VERSIONED_NAMESPACE_DECL
diff --git a/TAO/tao/Incoming_Message_Queue.cpp b/TAO/tao/Incoming_Message_Queue.cpp
index 979aa167918..155b87b4c82 100644
--- a/TAO/tao/Incoming_Message_Queue.cpp
+++ b/TAO/tao/Incoming_Message_Queue.cpp
@@ -212,34 +212,52 @@ TAO_Queued_Data::TAO_Queued_Data (const TAO_Queued_Data &qd)
/*static*/
TAO_Queued_Data *
-TAO_Queued_Data::make_queued_data (ACE_Allocator *alloc)
+TAO_Queued_Data::make_queued_data (ACE_Allocator *message_buffer_alloc,
+ ACE_Allocator *input_cdr_alloc,
+ ACE_Data_Block *db)
{
+ // Get a node for the queue..
TAO_Queued_Data *qd = 0;
- if (alloc)
+ if (message_buffer_alloc)
{
ACE_NEW_MALLOC_RETURN (qd,
static_cast<TAO_Queued_Data *> (
- alloc->malloc (sizeof (TAO_Queued_Data))),
- TAO_Queued_Data (alloc),
+ message_buffer_alloc->malloc (sizeof (TAO_Queued_Data))),
+ TAO_Queued_Data (message_buffer_alloc),
0);
- return qd;
}
-
- // No allocator, so use the global pool!
- // @@ TODO: We should be removing this at some point of time!
- if (TAO_debug_level == 4)
+ else
{
- // This debug is for testing purposes!
- ACE_DEBUG ((LM_DEBUG,
- "TAO (%P|%t) - Queued_Data::get_queued_data\n"
- "Using global pool for allocation \n"));
+ // No allocator, so use the global pool!
+ ACE_NEW_RETURN (qd,
+ TAO_Queued_Data,
+ 0);
}
- ACE_NEW_RETURN (qd,
- TAO_Queued_Data,
- 0);
+ // Providing an ACE_Data_Block indicates that the caller wants
+ // an aligned ACE_Message_Block added to the TAO_Queued_Data.
+ if (db != 0)
+ {
+ // If this allocation fails, the TAO_Queued_Data will be leaked.
+ if (input_cdr_alloc == 0)
+ ACE_NEW_RETURN (qd->msg_block_,
+ ACE_Message_Block (db,
+ 0,
+ input_cdr_alloc),
+ 0);
+ else
+ ACE_NEW_MALLOC_RETURN (qd->msg_block_,
+ static_cast<ACE_Message_Block*> (
+ input_cdr_alloc->malloc (sizeof (ACE_Message_Block))),
+ ACE_Message_Block (db,
+ 0,
+ input_cdr_alloc),
+ 0);
+
+ ACE_CDR::mb_align (qd->msg_block_);
+ }
return qd;
}
diff --git a/TAO/tao/Incoming_Message_Queue.h b/TAO/tao/Incoming_Message_Queue.h
index 80276c72b99..a70bfcbbcda 100644
--- a/TAO/tao/Incoming_Message_Queue.h
+++ b/TAO/tao/Incoming_Message_Queue.h
@@ -129,7 +129,10 @@ public:
TAO_Queued_Data (const TAO_Queued_Data &qd);
/// Creation of a node in the queue.
- static TAO_Queued_Data* make_queued_data (ACE_Allocator *alloc = 0);
+ static TAO_Queued_Data* make_queued_data (
+ ACE_Allocator *message_buffer_alloc = 0,
+ ACE_Allocator *input_cdr_alloc = 0,
+ ACE_Data_Block *db = 0);
/// Deletion of a node from the queue.
static void release (TAO_Queued_Data *qd);
diff --git a/TAO/tao/Leader_Follower.cpp b/TAO/tao/Leader_Follower.cpp
index 7f0eee155e3..5a49b4ec456 100644
--- a/TAO/tao/Leader_Follower.cpp
+++ b/TAO/tao/Leader_Follower.cpp
@@ -48,7 +48,11 @@ TAO_Leader_Follower::allocate_follower (void)
if (!this->follower_free_list_.empty ())
return this->follower_free_list_.pop_front ();
- return new TAO_LF_Follower (*this);
+ TAO_LF_Follower* ptr = 0;
+ ACE_NEW_RETURN (ptr,
+ TAO_LF_Follower (*this),
+ 0);
+ return ptr;
}
void
diff --git a/TAO/tao/LocalObject.h b/TAO/tao/LocalObject.h
index 11283cfaea6..d60a0be6a27 100644
--- a/TAO/tao/LocalObject.h
+++ b/TAO/tao/LocalObject.h
@@ -254,7 +254,7 @@ private:
protected:
/// Reference counter.
- ACE_Atomic_Op<TAO_SYNCH_MUTEX, CORBA::ULong> refcount_;
+ ACE_Atomic_Op<TAO_SYNCH_MUTEX, unsigned long> refcount_;
};
TAO_END_VERSIONED_NAMESPACE_DECL
diff --git a/TAO/tao/Messaging/AMH_Response_Handler.cpp b/TAO/tao/Messaging/AMH_Response_Handler.cpp
index 44d96d99ad5..0a1f3912dc9 100644
--- a/TAO/tao/Messaging/AMH_Response_Handler.cpp
+++ b/TAO/tao/Messaging/AMH_Response_Handler.cpp
@@ -234,9 +234,7 @@ TAO_AMH_Response_Handler::_tao_rh_send_exception (CORBA::Exception &ex
void
TAO_AMH_Response_Handler::_remove_ref (void)
{
- const CORBA::ULong new_count = --this->refcount_;
-
- if (new_count > 0)
+ if (--this->refcount_ > 0)
return;
if (this->allocator_)
diff --git a/TAO/tao/ORB.cpp b/TAO/tao/ORB.cpp
index 32f678ad0b1..055fde725e6 100644
--- a/TAO/tao/ORB.cpp
+++ b/TAO/tao/ORB.cpp
@@ -142,8 +142,7 @@ void CORBA::ORB::InvalidName::_tao_decode (
// ****************************************************************
CORBA::ORB::ORB (TAO_ORB_Core *orb_core)
- : lock_ ()
- , refcount_ (1)
+ : refcount_ (1)
, orb_core_ (orb_core)
, use_omg_ior_format_ (1)
, timeout_ (0)
diff --git a/TAO/tao/ORB.h b/TAO/tao/ORB.h
index b232ea12aed..41f0bba0d24 100644
--- a/TAO/tao/ORB.h
+++ b/TAO/tao/ORB.h
@@ -37,6 +37,7 @@
#include "ace/Thread_Mutex.h"
#include "ace/Guard_T.h"
+#include "ace/Atomic_Op.h"
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
@@ -632,12 +633,9 @@ namespace CORBA
private:
- /// Lock required for mutual exclusion between multiple threads.
- TAO_SYNCH_MUTEX lock_;
-
/// Maintains a reference count of number of instantiations of the
/// ORB.
- CORBA::ULong refcount_;
+ ACE_Atomic_Op<TAO_SYNCH_MUTEX, unsigned long> refcount_;
/// The ORB_Core that created us....
TAO_ORB_Core * orb_core_;
diff --git a/TAO/tao/ORB.i b/TAO/tao/ORB.i
index 89ddfb694a1..6a34deb048b 100644
--- a/TAO/tao/ORB.i
+++ b/TAO/tao/ORB.i
@@ -11,25 +11,18 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE CORBA::ULong
CORBA::ORB::_incr_refcnt (void)
{
- ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
- guard,
- lock_,
- 0);
return ++this->refcount_;
}
ACE_INLINE CORBA::ULong
CORBA::ORB::_decr_refcnt (void)
{
- {
- ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, mon, this->lock_, 0);
- --this->refcount_;
-
- if (this->refcount_ != 0)
- {
- return this->refcount_;
- }
- }
+ CORBA::ULong count = --this->refcount_;
+
+ if (count != 0)
+ {
+ return count;
+ }
delete this;
return 0;
diff --git a/TAO/tao/ORB_Core.h b/TAO/tao/ORB_Core.h
index 5cbb2a4571e..3212778f74a 100644
--- a/TAO/tao/ORB_Core.h
+++ b/TAO/tao/ORB_Core.h
@@ -1217,7 +1217,7 @@ protected:
TAO::Transport_Queueing_Strategy *default_transport_queueing_strategy_;
/// Number of outstanding references to this object.
- CORBA::ULong refcount_;
+ ACE_Atomic_Op<TAO_SYNCH_MUTEX, unsigned long> refcount_;
/// Registry containing all registered policy factories.
TAO::PolicyFactory_Registry_Adapter *policy_factory_registry_;
diff --git a/TAO/tao/ORB_Core.i b/TAO/tao/ORB_Core.i
index 3f5f53cd423..5ec66789335 100644
--- a/TAO/tao/ORB_Core.i
+++ b/TAO/tao/ORB_Core.i
@@ -16,19 +16,15 @@ TAO_ORB_Core::configuration (void) const
ACE_INLINE CORBA::ULong
TAO_ORB_Core::_incr_refcnt (void)
{
- ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, this->lock_, 0);
return this->refcount_++;
}
ACE_INLINE CORBA::ULong
TAO_ORB_Core::_decr_refcnt (void)
{
- {
- ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, mon, this->lock_, 0);
- --this->refcount_;
- if (this->refcount_ != 0)
- return this->refcount_;
- }
+ CORBA::ULong count = --this->refcount_;
+ if (count != 0)
+ return count;
this->fini ();
return 0;
diff --git a/TAO/tao/Object.cpp b/TAO/tao/Object.cpp
index b08936b74b5..deefa4cbf6c 100644
--- a/TAO/tao/Object.cpp
+++ b/TAO/tao/Object.cpp
@@ -39,7 +39,7 @@ CORBA::Object::~Object (void)
if (this->protocol_proxy_)
(void) this->protocol_proxy_->_decr_refcnt ();
- delete this->refcount_lock_;
+ delete this->object_init_lock_;
}
CORBA::Object::Object (TAO_Stub * protocol_proxy,
@@ -51,8 +51,8 @@ CORBA::Object::Object (TAO_Stub * protocol_proxy,
, ior_ (0)
, orb_core_ (orb_core)
, protocol_proxy_ (protocol_proxy)
- , refcount_ (1)
- , refcount_lock_ (0)
+ , refcount_ ()
+ , object_init_lock_ (0)
{
/// This constructor should not be called when the protocol proxy is
/// null ie. when the object is a LocalObject. Assert that
@@ -62,9 +62,12 @@ CORBA::Object::Object (TAO_Stub * protocol_proxy,
if (this->orb_core_ == 0)
this->orb_core_ = this->protocol_proxy_->orb_core ();
- this->refcount_lock_ =
+ this->object_init_lock_ =
this->orb_core_->resource_factory ()->create_corba_object_lock ();
+ this->refcount_ =
+ this->orb_core_->resource_factory ()->create_corba_object_refcount ();
+
// Set the collocation marker on the stub. This may not be news to it.
// This may also change the stub's object proxy broker.
this->protocol_proxy_->is_collocated (collocated);
@@ -80,11 +83,14 @@ CORBA::Object::Object (IOP::IOR *ior,
, ior_ (ior)
, orb_core_ (orb_core)
, protocol_proxy_ (0)
- , refcount_ (1)
- , refcount_lock_ (0)
+ , refcount_ ()
+ , object_init_lock_ (0)
{
- this->refcount_lock_ =
+ this->object_init_lock_ =
this->orb_core_->resource_factory ()->create_corba_object_lock ();
+
+ this->refcount_ =
+ this->orb_core_->resource_factory ()->create_corba_object_refcount ();
}
// Too lazy to do this check in every method properly! This is useful
@@ -92,14 +98,15 @@ CORBA::Object::Object (IOP::IOR *ior,
#define TAO_OBJECT_IOR_EVALUATE \
if (!this->is_evaluated_) \
{ \
- ACE_GUARD (ACE_Lock , mon, *this->refcount_lock_); \
- CORBA::Object::tao_object_initialize (this); \
+ ACE_GUARD (ACE_Lock , mon, *this->object_init_lock_); \
+ if (!this->is_evaluated_) \
+ CORBA::Object::tao_object_initialize (this); \
}
#define TAO_OBJECT_IOR_EVALUATE_RETURN \
if (!this->is_evaluated_) \
{ \
- ACE_GUARD_RETURN (ACE_Lock , mon, *this->refcount_lock_, 0); \
+ ACE_GUARD_RETURN (ACE_Lock , mon, *this->object_init_lock_, 0); \
if (!this->is_evaluated_) \
CORBA::Object::tao_object_initialize (this); \
}
@@ -110,13 +117,7 @@ CORBA::Object::_add_ref (void)
if (this->is_local_)
return;
- ACE_ASSERT (this->refcount_lock_ != 0);
-
- ACE_GUARD (ACE_Lock ,
- mon,
- *this->refcount_lock_);
-
- this->refcount_++;
+ this->refcount_.increment ();
}
void
@@ -125,20 +126,8 @@ CORBA::Object::_remove_ref (void)
if (this->is_local_)
return;
- ACE_ASSERT (this->refcount_lock_ != 0);
-
- {
- ACE_GUARD (ACE_Lock,
- mon,
- *this->refcount_lock_);
-
- this->refcount_--;
-
- if (this->refcount_ != 0)
- return;
- }
-
- ACE_ASSERT (this->refcount_ == 0);
+ if (this->refcount_.decrement () != 0)
+ return;
delete this;
}
diff --git a/TAO/tao/Object.h b/TAO/tao/Object.h
index 39302c41a5a..a10bdb679de 100644
--- a/TAO/tao/Object.h
+++ b/TAO/tao/Object.h
@@ -32,6 +32,7 @@
#include "tao/Object_Argument_T.h"
#include "tao/Arg_Traits_T.h"
#include "tao/Any_Insert_Policy_T.h"
+#include "tao/Configurable_Refcount.h"
#if defined (HPUX) && defined (IOR)
/* HP-UX 11.11 defines IOR in /usr/include/pa/inline.h
@@ -406,7 +407,7 @@ namespace CORBA
TAO_Stub * protocol_proxy_;
/// Number of outstanding references to this object.
- CORBA::ULong refcount_;
+ TAO_Configurable_Refcount refcount_;
/// Protect reference count manipulation from race conditions.
/**
@@ -415,7 +416,7 @@ namespace CORBA
* not require reference counting (the default) may be
* instantiated in the critical path.
*/
- ACE_Lock * refcount_lock_;
+ ACE_Lock * object_init_lock_;
};
} // End CORBA namespace.
diff --git a/TAO/tao/Object.i b/TAO/tao/Object.i
index 0db6581b912..e8c1606bb73 100644
--- a/TAO/tao/Object.i
+++ b/TAO/tao/Object.i
@@ -13,8 +13,8 @@ CORBA::Object::Object (int)
ior_ (),
orb_core_ (0),
protocol_proxy_ (0),
- refcount_ (1),
- refcount_lock_ (0)
+ refcount_ (),
+ object_init_lock_ (0)
{
}
diff --git a/TAO/tao/PortableServer/POA_Current_Impl.cpp b/TAO/tao/PortableServer/POA_Current_Impl.cpp
index 1c1e81b55c2..eab3e4d0e4f 100644
--- a/TAO/tao/PortableServer/POA_Current_Impl.cpp
+++ b/TAO/tao/PortableServer/POA_Current_Impl.cpp
@@ -23,7 +23,7 @@ namespace TAO
{
POA_Current_Impl::POA_Current_Impl (void)
: poa_ (0),
- object_id_ (),
+ object_id_ (TAO_POA_OBJECT_ID_BUF_SIZE, 0, object_id_buf_),
object_key_ (0),
servant_ (0),
priority_ (TAO_INVALID_PRIORITY),
diff --git a/TAO/tao/PortableServer/POA_Current_Impl.h b/TAO/tao/PortableServer/POA_Current_Impl.h
index 47f2a03994c..c14df79916d 100644
--- a/TAO/tao/PortableServer/POA_Current_Impl.h
+++ b/TAO/tao/PortableServer/POA_Current_Impl.h
@@ -25,6 +25,10 @@
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
+#ifndef TAO_POA_OBJECT_ID_BUF_SIZE
+#define TAO_POA_OBJECT_ID_BUF_SIZE 512
+#endif /* TAO_POA_OBJECT_ID_BUF_SIZE */
+
namespace TAO
{
namespace Portable_Server
@@ -146,6 +150,10 @@ namespace TAO
/// The POA implementation invoking an upcall
::TAO_Root_POA *poa_;
+ /// In order to avoid memory allocations, we will populate
+ /// the object id with this buffer.
+ CORBA::Octet object_id_buf_[TAO_POA_OBJECT_ID_BUF_SIZE];
+
/**
* The object ID of the current context. This is the user id and
* not the id the goes into the IOR. Note also that unlike the
diff --git a/TAO/tao/PortableServer/POA_Current_Impl.inl b/TAO/tao/PortableServer/POA_Current_Impl.inl
index db220558ae6..cf3fee49d65 100644
--- a/TAO/tao/PortableServer/POA_Current_Impl.inl
+++ b/TAO/tao/PortableServer/POA_Current_Impl.inl
@@ -25,7 +25,22 @@ namespace TAO
ACE_INLINE void
POA_Current_Impl::object_id (const PortableServer::ObjectId &id)
{
- this->object_id_ = id;
+ if (this->object_id_.release () ||
+ this->object_id_.get_buffer() == this->object_id_buf_)
+ {
+ // Resize the current object_id_. If it is less than the
+ // length of the current buffer, no allocation will take place.
+ size_t id_size = id.length ();
+ this->object_id_.length (id_size);
+
+ // Get the buffer and copy the new object id in it's place.
+ ACE_OS::memcpy (this->object_id_.get_buffer (),
+ id.get_buffer (), id_size);
+ }
+ else
+ {
+ this->object_id_ = id;
+ }
}
ACE_INLINE const PortableServer::ObjectId &
@@ -38,6 +53,8 @@ namespace TAO
POA_Current_Impl::replace_object_id (
const PortableServer::ObjectId &system_id)
{
+ // This has the effect of replacing the underlying buffer
+ // with that of another object id without copying.
object_id_.replace (system_id.maximum (),
system_id.length (),
const_cast <CORBA::Octet *> (system_id.get_buffer ()),
diff --git a/TAO/tao/PortableServer/Root_POA.cpp b/TAO/tao/PortableServer/Root_POA.cpp
index 945aafd7c2b..a1fa33136ac 100644
--- a/TAO/tao/PortableServer/Root_POA.cpp
+++ b/TAO/tao/PortableServer/Root_POA.cpp
@@ -1776,14 +1776,11 @@ TAO_Root_POA::parse_key (const TAO::ObjectKey &key,
CORBA::Boolean &is_system_id,
TAO::Portable_Server::Temporary_Creation_Time &poa_creation_time)
{
- // Start at zero.
- CORBA::ULong starting_at = 0;
-
// Get the object key octets.
const CORBA::Octet *key_data = key.get_buffer ();
// Skip the object key prefix since we have already checked for this.
- starting_at += TAO_OBJECTKEY_PREFIX_SIZE;
+ CORBA::ULong starting_at = TAO_OBJECTKEY_PREFIX_SIZE;
// Check the root indicator.
char root_key_type = key_data[starting_at];
diff --git a/TAO/tao/PortableServer/Servant_Upcall.cpp b/TAO/tao/PortableServer/Servant_Upcall.cpp
index 2842aec5bcb..9e5ef598e2b 100644
--- a/TAO/tao/PortableServer/Servant_Upcall.cpp
+++ b/TAO/tao/PortableServer/Servant_Upcall.cpp
@@ -34,7 +34,7 @@ namespace TAO
poa_ (0),
servant_ (0),
state_ (INITIAL_STAGE),
- system_id_ (),
+ system_id_ (TAO_POA_OBJECT_ID_BUF_SIZE, 0, system_id_buf_),
user_id_ (0),
current_context_ (),
#if (TAO_HAS_MINIMUM_POA == 0)
diff --git a/TAO/tao/PortableServer/Servant_Upcall.h b/TAO/tao/PortableServer/Servant_Upcall.h
index 18818009aab..427934e4faa 100644
--- a/TAO/tao/PortableServer/Servant_Upcall.h
+++ b/TAO/tao/PortableServer/Servant_Upcall.h
@@ -205,6 +205,7 @@ namespace TAO
State state_;
+ CORBA::Octet system_id_buf_[TAO_POA_OBJECT_ID_BUF_SIZE];
PortableServer::ObjectId system_id_;
const PortableServer::ObjectId *user_id_;
diff --git a/TAO/tao/Principal.h b/TAO/tao/Principal.h
index 3b995e143ca..fbdb6c9df84 100644
--- a/TAO/tao/Principal.h
+++ b/TAO/tao/Principal.h
@@ -94,7 +94,7 @@ namespace CORBA
private:
/// Reference counter.
- ACE_Atomic_Op<TAO_SYNCH_MUTEX, CORBA::ULong> refcount_;
+ ACE_Atomic_Op<TAO_SYNCH_MUTEX, unsigned long> refcount_;
};
} // End CORBA namespace
diff --git a/TAO/tao/Profile.cpp b/TAO/tao/Profile.cpp
index d0366ce3da0..ef5900c8b6c 100644
--- a/TAO/tao/Profile.cpp
+++ b/TAO/tao/Profile.cpp
@@ -41,13 +41,9 @@ TAO_Profile::TAO_Profile (CORBA::ULong tag,
, tag_ (tag)
, orb_core_ (orb_core)
, forward_to_ (0)
- , refcount_lock_ (0)
- , refcount_ (1)
+ , refcount_ (this->orb_core_->
+ client_factory ()->create_profile_refcount ())
{
- // @@ NOTE: Need to probably use a different type of lock.
- this->refcount_lock_ =
- this->orb_core_->client_factory ()->create_profile_lock ();
-
(void) this->orb_core_->object_key_table ().bind (obj_key,
this->ref_object_key_);
}
@@ -63,12 +59,9 @@ TAO_Profile::TAO_Profile (CORBA::ULong tag,
, tag_ (tag)
, orb_core_ (orb_core)
, forward_to_ (0)
- , refcount_lock_ (0)
- , refcount_ (1)
+ , refcount_ (this->orb_core_->
+ client_factory ()->create_profile_refcount ())
{
- // @@ NOTE: Need to probably use a different type of lock.
- this->refcount_lock_ =
- this->orb_core_->client_factory ()->create_profile_lock ();
}
TAO_Profile::~TAO_Profile (void)
@@ -79,7 +72,6 @@ TAO_Profile::~TAO_Profile (void)
}
this->orb_core_->object_key_table ().unbind (this->ref_object_key_);
- delete this->refcount_lock_;
//@@ TAO_PROFILE_SPL_DESTRUCTOR_ADD_HOOK
}
@@ -87,22 +79,15 @@ TAO_Profile::~TAO_Profile (void)
CORBA::ULong
TAO_Profile::_incr_refcnt (void)
{
- ACE_GUARD_RETURN (ACE_Lock, guard, *this->refcount_lock_, 0);
- return ++this->refcount_;
+ return this->refcount_.increment ();
}
CORBA::ULong
TAO_Profile::_decr_refcnt (void)
{
- {
- ACE_GUARD_RETURN (ACE_Lock, mon, *this->refcount_lock_, 0);
- --this->refcount_;
-
- if (this->refcount_ != 0)
- {
- return this->refcount_;
- }
- }
+ CORBA::ULong count = this->refcount_.decrement ();
+ if (count != 0)
+ return count;
// refcount is 0, so delete us!
// delete will call our ~ destructor which in turn deletes stuff.
diff --git a/TAO/tao/Profile.h b/TAO/tao/Profile.h
index 5462bd8010d..d9164b8e94c 100644
--- a/TAO/tao/Profile.h
+++ b/TAO/tao/Profile.h
@@ -24,6 +24,7 @@
#include "tao/GIOP_Message_Version.h"
#include "tao/Refcounted_ObjectKey.h"
#include "tao/Service_Callbacks.h"
+#include "tao/Configurable_Refcount.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
class ACE_Lock;
@@ -375,11 +376,8 @@ private:
/// object.
TAO_MProfile* forward_to_;
- /// Mutex to protect reference count.
- ACE_Lock *refcount_lock_;
-
/// Number of outstanding references to this object.
- CORBA::ULong refcount_;
+ TAO_Configurable_Refcount refcount_;
//@@ TAO_PROFILE_SPL_PRIVATE_DATA_ADD_HOOK
};
diff --git a/TAO/tao/RTCORBA/Thread_Pool.cpp b/TAO/tao/RTCORBA/Thread_Pool.cpp
index f63d8809bb5..32476bbef4b 100644
--- a/TAO/tao/RTCORBA/Thread_Pool.cpp
+++ b/TAO/tao/RTCORBA/Thread_Pool.cpp
@@ -486,15 +486,16 @@ TAO_Thread_Pool::TAO_Thread_Pool (TAO_Thread_Pool_Manager &manager,
ACE_THROW (CORBA::NO_IMPLEMENT ());
// Create one lane.
- this->lanes_ = new TAO_Thread_Lane *[this->number_of_lanes_];
- this->lanes_[0] =
- new TAO_Thread_Lane (*this,
- 0,
- default_priority,
- static_threads,
- dynamic_threads,
- dynamic_thread_idle_timeout
- ACE_ENV_ARG_PARAMETER);
+ ACE_NEW (this->lanes_,
+ TAO_Thread_Lane *[this->number_of_lanes_]);
+ ACE_NEW (this->lanes_[0],
+ TAO_Thread_Lane (*this,
+ 0,
+ default_priority,
+ static_threads,
+ dynamic_threads,
+ dynamic_thread_idle_timeout
+ ACE_ENV_ARG_PARAMETER));
}
TAO_Thread_Pool::TAO_Thread_Pool (TAO_Thread_Pool_Manager &manager,
@@ -525,18 +526,19 @@ TAO_Thread_Pool::TAO_Thread_Pool (TAO_Thread_Pool_Manager &manager,
ACE_THROW (CORBA::NO_IMPLEMENT ());
// Create multiple lane.
- this->lanes_ = new TAO_Thread_Lane *[this->number_of_lanes_];
+ ACE_NEW (this->lanes_,
+ TAO_Thread_Lane *[this->number_of_lanes_]);
for (CORBA::ULong i = 0;
i != this->number_of_lanes_;
++i)
- this->lanes_[i] =
- new TAO_Thread_Lane (*this,
- i,
- lanes[i].lane_priority,
- lanes[i].static_threads,
- lanes[i].dynamic_threads,
- dynamic_thread_idle_timeout
- ACE_ENV_ARG_PARAMETER);
+ ACE_NEW (this->lanes_[i],
+ TAO_Thread_Lane (*this,
+ i,
+ lanes[i].lane_priority,
+ lanes[i].static_threads,
+ lanes[i].dynamic_threads,
+ dynamic_thread_idle_timeout
+ ACE_ENV_ARG_PARAMETER));
}
void
diff --git a/TAO/tao/Resource_Factory.cpp b/TAO/tao/Resource_Factory.cpp
index 2f629c3331b..20a72732aa8 100644
--- a/TAO/tao/Resource_Factory.cpp
+++ b/TAO/tao/Resource_Factory.cpp
@@ -217,6 +217,13 @@ TAO_Resource_Factory::create_corba_object_lock (void)
return 0;
}
+TAO_Configurable_Refcount
+TAO_Resource_Factory::create_corba_object_refcount (void)
+{
+ return TAO_Configurable_Refcount (
+ TAO_Configurable_Refcount::TAO_NULL_LOCK);
+}
+
int
TAO_Resource_Factory::load_default_protocols (void)
{
diff --git a/TAO/tao/Resource_Factory.h b/TAO/tao/Resource_Factory.h
index 1fae24ea22b..580092f2887 100644
--- a/TAO/tao/Resource_Factory.h
+++ b/TAO/tao/Resource_Factory.h
@@ -24,6 +24,7 @@
#include "tao/Versioned_Namespace.h"
#include "tao/Basic_Types.h"
+#include "tao/Configurable_Refcount.h"
#include "ace/Service_Object.h"
#include "ace/Unbounded_Set.h"
@@ -231,6 +232,9 @@ public:
/// Creates the lock for the CORBA Object
virtual ACE_Lock *create_corba_object_lock (void);
+ /// Creates the configurable refcount for the CORBA Object
+ virtual TAO_Configurable_Refcount create_corba_object_refcount (void);
+
/// Creates the flushing strategy. The new instance is owned by the
/// caller.
virtual TAO_Flushing_Strategy *create_flushing_strategy (void) = 0;
diff --git a/TAO/tao/Stub.cpp b/TAO/tao/Stub.cpp
index b3e93fbd1d0..b7a03fdeedc 100644
--- a/TAO/tao/Stub.cpp
+++ b/TAO/tao/Stub.cpp
@@ -354,9 +354,7 @@ TAO_Stub::_incr_refcnt (void)
void
TAO_Stub::_decr_refcnt (void)
{
- const CORBA::ULong new_count = --this->refcount_;
-
- if (new_count == 0)
+ if (--this->refcount_ == 0)
delete this;
}
diff --git a/TAO/tao/Stub.h b/TAO/tao/Stub.h
index d9f8eb671a5..000be6649a4 100644
--- a/TAO/tao/Stub.h
+++ b/TAO/tao/Stub.h
@@ -384,7 +384,7 @@ protected:
CORBA::Boolean profile_success_;
/// Reference counter.
- ACE_Atomic_Op<TAO_SYNCH_MUTEX, CORBA::ULong> refcount_;
+ ACE_Atomic_Op<TAO_SYNCH_MUTEX, unsigned long> refcount_;
/// The policy overrides in this object, if nil then use the default
/// policies.
diff --git a/TAO/tao/TAO_Server_Request.cpp b/TAO/tao/TAO_Server_Request.cpp
index 3b1b8e61d94..d2a06026561 100644
--- a/TAO/tao/TAO_Server_Request.cpp
+++ b/TAO/tao/TAO_Server_Request.cpp
@@ -54,7 +54,9 @@ TAO_ServerRequest::TAO_ServerRequest (TAO_Pluggable_Messaging *mesg_base,
TAO_Transport *transport,
TAO_ORB_Core *orb_core)
: mesg_base_ (mesg_base),
- operation_ (),
+ operation_ (0),
+ operation_len_ (0),
+ release_operation_ (false),
incoming_ (&input),
outgoing_ (&output),
// transport already duplicated in
@@ -97,7 +99,9 @@ TAO_ServerRequest::TAO_ServerRequest (TAO_Pluggable_Messaging *mesg_base,
TAO_ORB_Core *orb_core,
int &parse_error)
: mesg_base_ (mesg_base),
- operation_ (operation),
+ operation_ (CORBA::string_dup (operation)),
+ operation_len_ (operation == 0 ? 0 : ACE_OS::strlen (operation)),
+ release_operation_ (true),
incoming_ (0),
outgoing_ (&output),
// transport already duplicated in
@@ -133,6 +137,8 @@ TAO_ServerRequest::TAO_ServerRequest (TAO_ORB_Core * orb_core,
CORBA::Object_ptr target)
: mesg_base_ (0),
operation_ (details.opname ()),
+ operation_len_ (details.opname_len ()),
+ release_operation_ (false),
incoming_ (0),
outgoing_ (0),
transport_ (0),
diff --git a/TAO/tao/TAO_Server_Request.h b/TAO/tao/TAO_Server_Request.h
index d2e4d4efde7..f1e065ba020 100644
--- a/TAO/tao/TAO_Server_Request.h
+++ b/TAO/tao/TAO_Server_Request.h
@@ -279,10 +279,20 @@ public:
#endif /* TAO_HAS_INTERCEPTORS == 1 */
private:
+ /// Default ctor only used to create a TAO_ServerRequest that is about
+ /// to be the target of a clone operation.
+ TAO_ServerRequest (void);
+
TAO_Pluggable_Messaging *mesg_base_;
/// Operation name.
- ACE_CString operation_;
+ const char* operation_;
+
+ /// Operation length.
+ size_t operation_len_;
+
+ /// Do we own the memory associated with operation_?
+ bool release_operation_;
CORBA::Object_var forward_location_;
diff --git a/TAO/tao/TAO_Server_Request.i b/TAO/tao/TAO_Server_Request.i
index 5fc7f50ab9b..34d7096e65d 100644
--- a/TAO/tao/TAO_Server_Request.i
+++ b/TAO/tao/TAO_Server_Request.i
@@ -2,8 +2,44 @@
//
// $Id$
+#include "tao/GIOP_Utils.h"
+
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
+// This constructor is used by the CSD clone.
+ACE_INLINE
+TAO_ServerRequest::TAO_ServerRequest (void)
+ : mesg_base_ (0),
+ operation_ (0),
+ operation_len_ (0),
+ release_operation_ (false),
+ incoming_ (0),
+ outgoing_ (0),
+ transport_(0),
+ response_expected_ (false),
+ deferred_reply_ (false),
+ sync_with_server_ (false),
+ is_dsi_ (false),
+ exception_type_ (TAO_GIOP_NO_EXCEPTION),
+ orb_core_ (0),
+ request_id_ (0),
+ profile_ (0),
+ requesting_principal_ (0),
+ dsi_nvlist_align_ (0),
+ operation_details_ (0),
+ argument_flag_ (1)
+#if TAO_HAS_INTERCEPTORS == 1
+ , interceptor_count_ (0)
+ , rs_pi_current_ ()
+ , result_seq_ (0)
+ , caught_exception_ (0)
+ , reply_status_ (-1)
+#endif /* TAO_HAS_INTERCEPTORS == 1 */
+{
+ if (this->release_operation_)
+ CORBA::string_free (const_cast<char*> (this->operation_));
+}
+
ACE_INLINE TAO_ORB_Core *
TAO_ServerRequest::orb_core (void) const
{
@@ -25,7 +61,7 @@ TAO_ServerRequest::outgoing (void) const
ACE_INLINE const char *
TAO_ServerRequest::operation (void) const
{
- return this->operation_.c_str ();
+ return (this->operation_ == 0 ? "" : this->operation_);
}
ACE_INLINE void
@@ -33,20 +69,18 @@ TAO_ServerRequest::operation (const char *operation,
size_t length,
int release)
{
- if (length == 0)
- {
- this->operation_.set (operation, release);
- }
- else
- {
- this->operation_.set (operation, length, release);
- }
+ if (this->release_operation_)
+ CORBA::string_free (const_cast <char*> (this->operation_));
+
+ this->operation_len_ = (length == 0 ? ACE_OS::strlen (operation) : length);
+ this->release_operation_ = release;
+ this->operation_ = operation;
}
ACE_INLINE size_t
TAO_ServerRequest::operation_length (void) const
{
- return this->operation_.length ();
+ return this->operation_len_;
}
ACE_INLINE CORBA::Boolean
diff --git a/TAO/tao/TAO_Singleton_Manager.cpp b/TAO/tao/TAO_Singleton_Manager.cpp
index 658c2bdff74..4438d66db11 100644
--- a/TAO/tao/TAO_Singleton_Manager.cpp
+++ b/TAO/tao/TAO_Singleton_Manager.cpp
@@ -63,12 +63,16 @@ TAO_Singleton_Manager::TAO_Singleton_Manager (void)
exit_info_ (),
registered_with_object_manager_ (-1)
#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
- , internal_lock_ (new TAO_SYNCH_RECURSIVE_MUTEX)
+ , internal_lock_ (0)
# endif /* ACE_MT_SAFE */
#if defined (ACE_HAS_EXCEPTIONS)
, old_unexpected_ (0)
#endif /* ACE_HAS_EXCEPTIONS */
{
+#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
+ ACE_NEW (this->internal_lock_,
+ TAO_SYNCH_RECURSIVE_MUTEX);
+# endif /* ACE_MT_SAFE */
// Be sure that no further instances are created via instance ().
if (the_instance == 0)
{
diff --git a/TAO/tao/Tagged_Profile.cpp b/TAO/tao/Tagged_Profile.cpp
index e5bed686c15..b3886f8150b 100644
--- a/TAO/tao/Tagged_Profile.cpp
+++ b/TAO/tao/Tagged_Profile.cpp
@@ -174,9 +174,8 @@ TAO_Tagged_Profile::unmarshall_ref_addr_i (
if (hdr_status)
{
- // Set the type_id
- this->type_id_.set (input.rd_ptr (),
- 0);
+ // Set the type_id (it is not owned by this object)
+ this->type_id_ = input.rd_ptr ();
input.skip_bytes (id_length);
}
diff --git a/TAO/tao/Tagged_Profile.h b/TAO/tao/Tagged_Profile.h
index 541cb4362a4..3900de617c1 100644
--- a/TAO/tao/Tagged_Profile.h
+++ b/TAO/tao/Tagged_Profile.h
@@ -79,7 +79,7 @@ public:
/// Accessor to the type_id contained in the IOP::IOR received from
/// the client.
- const ACE_CString &type_id (void) const;
+ const char* type_id (void) const;
CORBA::Short discriminator (void) const;
@@ -141,7 +141,7 @@ private:
/// The type_id in the IOP::IOR in case we receive the
/// GIOP::IORAddressingInfo information.
- ACE_CString type_id_;
+ const char* type_id_;
};
TAO_END_VERSIONED_NAMESPACE_DECL
diff --git a/TAO/tao/Tagged_Profile.i b/TAO/tao/Tagged_Profile.i
index 60249f0ef37..688bcd6a0ba 100644
--- a/TAO/tao/Tagged_Profile.i
+++ b/TAO/tao/Tagged_Profile.i
@@ -11,7 +11,7 @@ TAO_Tagged_Profile::TAO_Tagged_Profile (TAO_ORB_Core *orb_core)
object_key_ (),
profile_ (),
profile_index_ (0),
- type_id_ ()
+ type_id_ (0)
{
}
@@ -52,10 +52,10 @@ TAO_Tagged_Profile::profile_index (void) const
return this->profile_index_;
}
-ACE_INLINE const ACE_CString &
+ACE_INLINE const char*
TAO_Tagged_Profile::type_id (void) const
{
- return this->type_id_;
+ return this->type_id_ == 0 ? "" : this->type_id_;
}
ACE_INLINE CORBA::Short
diff --git a/TAO/tao/Valuetype/ValueBase.h b/TAO/tao/Valuetype/ValueBase.h
index 413b0a62801..6918787b738 100644
--- a/TAO/tao/Valuetype/ValueBase.h
+++ b/TAO/tao/Valuetype/ValueBase.h
@@ -287,7 +287,7 @@ namespace CORBA
private: // data
/// Reference counter.
- ACE_Atomic_Op<TAO_SYNCH_MUTEX, CORBA::ULong> refcount_;
+ ACE_Atomic_Op<TAO_SYNCH_MUTEX, unsigned long> refcount_;
}; // DefaultValueRefCountBase
// which lock has the lowest memory overhead ?
diff --git a/TAO/tao/Var_Size_Argument_T.cpp b/TAO/tao/Var_Size_Argument_T.cpp
index 570c37ceb20..a185d49ed28 100644
--- a/TAO/tao/Var_Size_Argument_T.cpp
+++ b/TAO/tao/Var_Size_Argument_T.cpp
@@ -78,7 +78,11 @@ TAO::Out_Var_Size_Argument_T<S,Insert_Policy>::demarshal (
TAO_InputCDR & cdr
)
{
+#if defined (ACE_HAS_NEW_NOTHROW)
+ this->x_ = new (ACE_nothrow) S;
+#else
this->x_ = new S;
+#endif /* ACE_HAS_NEW_NOTHROW */
return cdr >> *this->x_;
}
diff --git a/TAO/tao/default_client.cpp b/TAO/tao/default_client.cpp
index 6076024c440..b2c7aad11c5 100644
--- a/TAO/tao/default_client.cpp
+++ b/TAO/tao/default_client.cpp
@@ -106,8 +106,8 @@ TAO_Default_Client_Strategy_Factory::parse_args (int argc, ACE_TCHAR* argv[])
else if (ACE_OS::strcasecmp (name,
ACE_TEXT("null")) == 0)
this->profile_lock_type_ = TAO_NULL_LOCK;
- else
- this->report_option_value_error (ACE_TEXT("-ORBIIOPProfileLock"), name);
+ else
+ this->report_option_value_error (ACE_TEXT("-ORBIIOPProfileLock"), name);
}
}
@@ -218,7 +218,7 @@ TAO_Default_Client_Strategy_Factory::parse_args (int argc, ACE_TCHAR* argv[])
else if (ACE_OS::strcmp (name, ACE_TEXT("1")) == 0 ||
ACE_OS::strcasecmp (name, ACE_TEXT("true")) == 0)
this->use_cleanup_options_ = true;
- else
+ else
this->report_option_value_error (ACE_TEXT("-ORBConnectionHandlerCleanup"), name);
}
}
@@ -261,6 +261,21 @@ TAO_Default_Client_Strategy_Factory::create_profile_lock (void)
return the_lock;
}
+TAO_Configurable_Refcount
+TAO_Default_Client_Strategy_Factory::create_profile_refcount (void)
+{
+ switch (this->profile_lock_type_)
+ {
+ case TAO_NULL_LOCK:
+ return TAO_Configurable_Refcount (
+ TAO_Configurable_Refcount::TAO_NULL_LOCK);
+ case TAO_THREAD_LOCK:
+ default:
+ return TAO_Configurable_Refcount (
+ TAO_Configurable_Refcount::TAO_THREAD_LOCK);
+ }
+}
+
// Create the correct client transport muxing strategy.
TAO_Transport_Mux_Strategy *
TAO_Default_Client_Strategy_Factory::create_transport_mux_strategy (TAO_Transport *transport)
diff --git a/TAO/tao/default_client.h b/TAO/tao/default_client.h
index e1660fb2041..3fd00513949 100644
--- a/TAO/tao/default_client.h
+++ b/TAO/tao/default_client.h
@@ -54,6 +54,7 @@ public:
// = Check Client_Strategy_Factory.h for the documentation of the
// following methods.
virtual ACE_Lock* create_profile_lock (void);
+ virtual TAO_Configurable_Refcount create_profile_refcount (void);
virtual TAO_Transport_Mux_Strategy *create_transport_mux_strategy (TAO_Transport *transport);
virtual ACE_Lock *create_transport_mux_strategy_lock (void);
virtual int reply_dispatcher_table_size (void) const;
diff --git a/TAO/tao/default_resource.cpp b/TAO/tao/default_resource.cpp
index 988b98a3f6d..86385720c98 100644
--- a/TAO/tao/default_resource.cpp
+++ b/TAO/tao/default_resource.cpp
@@ -565,8 +565,9 @@ TAO_Default_Resource_Factory::get_parser_names (char **&names,
// OK fallback on the hardcoded ones....
this->parser_names_count_ = 5; // HOW MANY DO WE HAVE?
- this->parser_names_ =
- new char *[this->parser_names_count_];
+ ACE_NEW_RETURN (this->parser_names_,
+ char *[this->parser_names_count_],
+ -1);
CORBA::ULong index = 0;
@@ -1109,6 +1110,21 @@ TAO_Default_Resource_Factory::create_corba_object_lock (void)
return the_lock;
}
+TAO_Configurable_Refcount
+TAO_Default_Resource_Factory::create_corba_object_refcount (void)
+{
+ switch (this->corba_object_lock_type_)
+ {
+ case TAO_NULL_LOCK:
+ return TAO_Configurable_Refcount (
+ TAO_Configurable_Refcount::TAO_NULL_LOCK);
+ case TAO_THREAD_LOCK:
+ default:
+ return TAO_Configurable_Refcount (
+ TAO_Configurable_Refcount::TAO_THREAD_LOCK);
+ }
+}
+
TAO_Flushing_Strategy *
TAO_Default_Resource_Factory::create_flushing_strategy (void)
{
diff --git a/TAO/tao/default_resource.h b/TAO/tao/default_resource.h
index 9cf29b89be8..924364b681c 100644
--- a/TAO/tao/default_resource.h
+++ b/TAO/tao/default_resource.h
@@ -130,6 +130,7 @@ public:
virtual int max_muxed_connections (void) const;
virtual ACE_Lock *create_cached_connection_lock (void);
virtual ACE_Lock *create_object_key_table_lock (void);
+ virtual TAO_Configurable_Refcount create_corba_object_refcount (void);
virtual ACE_Lock *create_corba_object_lock (void);
virtual int locked_transport_cache (void);
virtual TAO_Flushing_Strategy *create_flushing_strategy (void);
diff --git a/TAO/tao/tao.mpc b/TAO/tao/tao.mpc
index 6b959947cc3..7aa50efaa6a 100644
--- a/TAO/tao/tao.mpc
+++ b/TAO/tao/tao.mpc
@@ -34,6 +34,7 @@ project(TAO) : acelib, core, tao_output, taodefaults, pidl, extra_core, tao_vers
Collocated_Invocation.cpp
Collocation_Proxy_Broker.cpp
Collocation_Resolver.cpp
+ Configurable_Refcount.cpp
Connect_Strategy.cpp
Connection_Handler.cpp
Connection_Purging_Strategy.cpp