2 #include "tao/default_resource.h"
5 #include "tao/IIOP_Factory.h"
6 #include "tao/Acceptor_Registry.h"
7 #include "tao/Connector_Registry.h"
8 #include "tao/Reactive_Flushing_Strategy.h"
9 #include "tao/Block_Flushing_Strategy.h"
10 #include "tao/Leader_Follower_Flushing_Strategy.h"
11 #include "tao/LRU_Connection_Purging_Strategy.h"
12 #include "tao/LF_Strategy_Complete.h"
13 #include "tao/Codeset_Descriptor_Base.h"
14 #include "tao/Codeset_Manager_Factory_Base.h"
15 #include "tao/Codeset_Manager.h"
16 #include "tao/Null_Fragmentation_Strategy.h"
17 #include "tao/On_Demand_Fragmentation_Strategy.h"
18 #include "tao/MMAP_Allocator.h"
19 #include "tao/Load_Protocol_Factory_T.h"
20 #include "tao/Time_Policy_Manager.h"
22 #include "ace/TP_Reactor.h"
23 #include "ace/Malloc.h"
24 #include "ace/Reactor.h"
25 #include "ace/Malloc_T.h"
26 #include "ace/Local_Memory_Pool.h"
27 #include "ace/OS_NS_string.h"
28 #include "ace/OS_NS_strings.h"
32 #if !defined (__ACE_INLINE__)
33 #include "tao/default_resource.inl"
34 #endif /* __ACE_INLINE__ */
36 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
39 TAO_Codeset_Parameters::TAO_Codeset_Parameters ()
45 TAO_Codeset_Parameters::~TAO_Codeset_Parameters ()
47 for (TAO_Codeset_Parameters::iterator i
=
52 ACE_TCHAR
** element
= nullptr;
54 ACE_OS::free (*element
);
57 ACE_OS::free (this->native_
);
61 TAO_Codeset_Parameters::native ()
63 return (this->native_
);
67 TAO_Codeset_Parameters::apply_to (TAO_Codeset_Descriptor_Base
*csd
)
72 if (this->native () != nullptr)
73 csd
->ncs (this->native ());
75 ACE_TCHAR
** element
= nullptr;
76 for (TAO_Codeset_Parameters::iterator i
= this->translators ();
81 csd
->add_translator (*element
);
86 TAO_Codeset_Parameters::native (const ACE_TCHAR
* n
)
88 ACE_OS::free (this->native_
);
89 this->native_
= ACE_OS::strdup (n
);
93 TAO_Codeset_Parameters::add_translator (const ACE_TCHAR
*name
)
95 this->translators_
.enqueue_tail (ACE_OS::strdup (name
));
98 TAO_Codeset_Parameters::iterator
99 TAO_Codeset_Parameters::translators ()
101 return this->translators_
.begin ();
104 TAO_Default_Resource_Factory::TAO_Default_Resource_Factory ()
105 : use_locked_data_blocks_ (1)
106 , parser_names_count_ (0)
107 , parser_names_ (nullptr)
108 , protocol_factories_ ()
109 , connection_purging_type_ (TAO_CONNECTION_PURGING_STRATEGY
)
110 , cache_maximum_ (TAO_CONNECTION_CACHE_MAXIMUM
)
111 , purge_percentage_ (TAO_PURGE_PERCENT
)
112 , max_muxed_connections_ (0)
113 , reactor_mask_signals_ (1)
114 , dynamically_allocated_reactor_ (false)
115 , options_processed_ (0)
116 , factory_disabled_ (0)
117 #if TAO_USE_OUTPUT_CDR_MMAP_MEMORY_POOL == 1
118 , output_cdr_allocator_type_ (MMAP_ALLOCATOR
)
120 , output_cdr_allocator_type_ (DEFAULT
)
122 #if TAO_USE_LOCAL_MEMORY_POOL == 1
123 , use_local_memory_pool_ (true)
125 , use_local_memory_pool_ (false)
127 , cached_connection_lock_type_ (TAO_THREAD_LOCK
)
128 #if defined (TAO_USE_BLOCKING_FLUSHING)
129 , flushing_strategy_type_ (TAO_BLOCKING_FLUSHING
)
130 #elif defined (TAO_USE_REACTIVE_FLUSHING)
131 , flushing_strategy_type_ (TAO_REACTIVE_FLUSHING
)
133 , flushing_strategy_type_ (TAO_LEADER_FOLLOWER_FLUSHING
)
135 , char_codeset_parameters_ ()
136 , wchar_codeset_parameters_ ()
137 , resource_usage_strategy_ (TAO_Resource_Factory::TAO_EAGER
)
138 , drop_replies_ (true)
140 #if TAO_USE_LAZY_RESOURCE_USAGE_STRATEGY == 1
141 this->resource_usage_strategy_
=
142 TAO_Resource_Factory::TAO_LAZY
;
143 #endif /*TAO_USE_LAZY_RESOURCE_USAGE_STRATEGY*/
148 TAO_Default_Resource_Factory::~TAO_Default_Resource_Factory ()
150 const TAO_ProtocolFactorySetItor end
= this->protocol_factories_
.end ();
152 for (TAO_ProtocolFactorySetItor iterator
=
153 this->protocol_factories_
.begin ();
160 this->protocol_factories_
.reset ();
162 for (int i
= 0; i
< this->parser_names_count_
; ++i
)
163 CORBA::string_free (this->parser_names_
[i
]);
165 delete [] this->parser_names_
;
170 TAO_Default_Resource_Factory::init (int argc
, ACE_TCHAR
*argv
[])
172 ACE_TRACE ("TAO_Default_Resource_Factory::init");
174 // If this factory has already been disabled then
175 // print a warning and exit because any options
177 if (this->factory_disabled_
)
179 TAOLIB_DEBUG ((LM_WARNING
,
180 ACE_TEXT ("TAO (%P|%t) - Warning: Resource_Factory options ")
181 ACE_TEXT ("ignored. ")
182 ACE_TEXT ("Default Resource Factory is disabled\n")));
185 this->options_processed_
= 1;
187 this->parser_names_count_
= 0;
191 for (curarg
= 0; curarg
< argc
; ++curarg
)
193 // Parse thro' and find the number of Parsers to be loaded.
194 if (ACE_OS::strcasecmp (argv
[curarg
],
195 ACE_TEXT("-ORBIORParser")) == 0)
196 ++this->parser_names_count_
;
200 if (curarg
== (argc
-1) && this->parser_names_count_
!= 0)
202 // This is the last loop..
203 ACE_NEW_RETURN (this->parser_names_
,
204 char *[this->parser_names_count_
],
208 i
< this->parser_names_count_
;
210 this->parser_names_
[i
] = nullptr;
216 for (curarg
= 0; curarg
< argc
; ++curarg
)
218 if (ACE_OS::strcasecmp (argv
[curarg
],
219 ACE_TEXT("-ORBReactorMaskSignals")) == 0)
224 ACE_TCHAR
* name
= argv
[curarg
];
226 if (ACE_OS::strcasecmp (name
, ACE_TEXT("0")) == 0)
227 this->reactor_mask_signals_
= 0;
228 else if (ACE_OS::strcasecmp (name
, ACE_TEXT("1")) == 0)
229 this->reactor_mask_signals_
= 1;
231 this->report_option_value_error (ACE_TEXT("-ORBReactorMaskSignals"), name
);
235 else if (ACE_OS::strcasecmp (argv
[curarg
],
236 ACE_TEXT("-ORBProtocolFactory")) == 0)
238 TAO_ProtocolFactorySet
*pset
= this->get_protocol_factories ();
242 TAO_Protocol_Item
*item
= nullptr;
243 ACE_NEW_RETURN (item
,
244 TAO_Protocol_Item (ACE_TEXT_ALWAYS_CHAR(argv
[curarg
])),
246 if (pset
->insert (item
) == -1)
247 TAOLIB_ERROR ((LM_ERROR
,
248 ACE_TEXT ("(%P|%t) Unable to add protocol factories ")
249 ACE_TEXT ("for %s: %m\n"),
254 /// CodeSet Translators
255 else if (ACE_OS::strcasecmp (argv
[curarg
],
256 ACE_TEXT("-ORBNativeCharCodeSet")) == 0)
260 this->char_codeset_parameters_
.native (argv
[curarg
]);
263 else if (ACE_OS::strcasecmp (argv
[curarg
],
264 ACE_TEXT("-ORBNativeWCharCodeSet")) == 0)
268 this->wchar_codeset_parameters_
.native (argv
[curarg
]);
271 else if (ACE_OS::strcasecmp (argv
[curarg
],
272 ACE_TEXT("-ORBCharCodesetTranslator")) == 0)
276 this->char_codeset_parameters_
.add_translator (argv
[curarg
]);
279 /// CodeSet Translators
280 else if (ACE_OS::strcasecmp (argv
[curarg
],
281 ACE_TEXT("-ORBWCharCodesetTranslator")) == 0)
285 this->wchar_codeset_parameters_
.add_translator (argv
[curarg
]);
287 else if (ACE_OS::strcasecmp (argv
[curarg
],
288 ACE_TEXT("-ORBConnectionPurgingStrategy")) == 0)
294 ACE_TCHAR
* name
= argv
[curarg
];
296 if (ACE_OS::strcasecmp (name
,
297 ACE_TEXT("lru")) == 0)
298 this->connection_purging_type_
=
299 TAO_Resource_Factory::LRU
;
300 else if (ACE_OS::strcasecmp (name
,
301 ACE_TEXT("lfu")) == 0)
302 this->connection_purging_type_
=
303 TAO_Resource_Factory::LFU
;
304 else if (ACE_OS::strcasecmp (name
,
305 ACE_TEXT("fifo")) == 0)
306 this->connection_purging_type_
=
307 TAO_Resource_Factory::FIFO
;
308 else if (ACE_OS::strcasecmp (name
,
309 ACE_TEXT("null")) == 0)
310 this->connection_purging_type_
=
311 TAO_Resource_Factory::NOOP
;
313 this->report_option_value_error (ACE_TEXT("-ORBConnectionPurgingStrategy"), name
);
316 else if (ACE_OS::strcasecmp (argv
[curarg
],
317 ACE_TEXT("-ORBConnectionCacheMax")) == 0)
321 this->cache_maximum_
= ACE_OS::atoi (argv
[curarg
]);
323 this->report_option_value_error (ACE_TEXT("-ORBConnectionCacheMax"), argv
[curarg
]);
326 else if (ACE_OS::strcasecmp (argv
[curarg
],
327 ACE_TEXT("-ORBConnectionCachePurgePercentage")) == 0)
331 this->purge_percentage_
= ACE_OS::atoi (argv
[curarg
]);
333 this->report_option_value_error (ACE_TEXT("-ORBConnectionCachePurgePercentage"),
336 else if (ACE_OS::strcasecmp (argv
[curarg
],
337 ACE_TEXT("-ORBIORParser")) == 0)
343 this->add_to_ior_parser_names (ACE_TEXT_ALWAYS_CHAR(argv
[curarg
]));
347 else if (ACE_OS::strcasecmp (argv
[curarg
],
348 ACE_TEXT("-ORBConnectionCacheLock")) == 0)
353 ACE_TCHAR
* name
= argv
[curarg
];
355 if (ACE_OS::strcasecmp (name
,
356 ACE_TEXT("thread")) == 0)
357 this->cached_connection_lock_type_
= TAO_THREAD_LOCK
;
358 else if (ACE_OS::strcasecmp (name
,
359 ACE_TEXT("null")) == 0)
361 // @@ Bug 940 :This is a sort of hack now. We need to put
362 // this in a common place once we get the common
363 // switch that is documented in bug 940...
364 this->use_locked_data_blocks_
= 0;
365 this->cached_connection_lock_type_
= TAO_NULL_LOCK
;
368 this->report_option_value_error (ACE_TEXT("-ORBConnectionCacheLock"), name
);
371 else if (ACE_OS::strcasecmp (argv
[curarg
],
372 ACE_TEXT("-ORBResourceUsage")) == 0)
377 ACE_TCHAR
* name
= argv
[curarg
];
379 if (ACE_OS::strcasecmp (name
,
380 ACE_TEXT("eager")) == 0)
381 this->resource_usage_strategy_
= TAO_EAGER
;
382 else if (ACE_OS::strcasecmp (name
,
383 ACE_TEXT("lazy")) == 0)
385 this->resource_usage_strategy_
= TAO_LAZY
;
388 this->report_option_value_error (ACE_TEXT("-ORBResourceUsage"), name
);
391 else if (ACE_OS::strcasecmp (argv
[curarg
],
392 ACE_TEXT("-ORBFlushingStrategy")) == 0)
397 ACE_TCHAR
* name
= argv
[curarg
];
399 if (ACE_OS::strcasecmp (name
,
400 ACE_TEXT("leader_follower")) == 0)
401 this->flushing_strategy_type_
= TAO_LEADER_FOLLOWER_FLUSHING
;
402 else if (ACE_OS::strcasecmp (name
,
403 ACE_TEXT("reactive")) == 0)
404 this->flushing_strategy_type_
= TAO_REACTIVE_FLUSHING
;
405 else if (ACE_OS::strcasecmp (name
,
406 ACE_TEXT("blocking")) == 0)
407 this->flushing_strategy_type_
= TAO_BLOCKING_FLUSHING
;
409 this->report_option_value_error (ACE_TEXT("-ORBFlushingStrategy"), name
);
412 else if (ACE_OS::strcasecmp (argv
[curarg
],
413 ACE_TEXT ("-ORBMuxedConnectionMax")) == 0)
417 this->max_muxed_connections_
=
418 ACE_OS::atoi (argv
[curarg
]);
420 this->report_option_value_error (ACE_TEXT("-ORBMuxedConnectionMax"),
423 else if (ACE_OS::strcasecmp (argv
[curarg
],
424 ACE_TEXT("-ORBDropRepliesDuringShutdown")) == 0)
429 int const tmp
= ACE_OS::atoi (argv
[curarg
]);
432 this->drop_replies_
= false;
434 this->drop_replies_
= true;
437 this->report_option_value_error (ACE_TEXT("-ORBDropRepliesDuringShutdown"),
440 else if (0 == ACE_OS::strcasecmp (argv
[curarg
],
441 ACE_TEXT("-ORBOutputCDRAllocator")))
447 ACE_TCHAR
const * const current_arg
= argv
[curarg
];
449 if (ACE_OS::strcasecmp (current_arg
,
450 ACE_TEXT("mmap")) == 0)
452 #if TAO_HAS_SENDFILE == 1
453 this->output_cdr_allocator_type_
= MMAP_ALLOCATOR
;
455 TAOLIB_DEBUG ((LM_WARNING
,
456 ACE_TEXT ("MMAP allocator unsupport on this platform")));
457 #endif /* TAO_HAS_SENDFILE==1 */
459 else if (ACE_OS::strcasecmp (current_arg
,
460 ACE_TEXT("local_memory_pool")) == 0
461 && this->output_cdr_allocator_type_
!= DEFAULT
)
463 this->output_cdr_allocator_type_
= LOCAL_MEMORY_POOL
;
465 else if (ACE_OS::strcasecmp (current_arg
,
466 ACE_TEXT("default")) == 0)
468 this->output_cdr_allocator_type_
= DEFAULT
;
472 this->report_option_value_error (
473 ACE_TEXT("-ORBOutputCDRAllocator"), current_arg
);
477 else if (0 == ACE_OS::strcasecmp (argv
[curarg
],
478 ACE_TEXT("-ORBZeroCopyWrite")))
480 #if TAO_HAS_SENDFILE == 1
481 this->output_cdr_allocator_type_
= MMAP_ALLOCATOR
;
483 TAOLIB_DEBUG ((LM_WARNING
,
484 ACE_TEXT ("Zero copy writes unsupported on this platform\n")));
485 #endif /* TAO_HAS_SENDFILE==1 */
487 else if (ACE_OS::strncmp (argv
[curarg
],
491 // Can we assume there is an argument after the option?
493 TAOLIB_ERROR ((LM_ERROR
,
494 ACE_TEXT ("TAO (%P|%t) - Default_Resource_Factory - ")
495 ACE_TEXT ("unknown option <%s>\n"),
500 TAOLIB_DEBUG ((LM_DEBUG
,
501 ACE_TEXT ("TAO (%P|%t) - Default_Resource_Factory - ")
502 ACE_TEXT ("ignoring option <%s>\n"),
511 TAO_Default_Resource_Factory::get_parser_names (char **&names
,
512 int &number_of_names
)
514 if (this->parser_names_count_
!= 0)
516 // The user used some -ORBIORParser options, just return those.
517 names
= this->parser_names_
;
518 number_of_names
= this->parser_names_count_
;
523 this->parser_names_count_
= 0;
524 #if (TAO_HAS_DDL_PARSER == 1)
525 ++this->parser_names_count_
;
527 #if (TAO_HAS_FILE_PARSER == 1)
528 ++this->parser_names_count_
;
530 #if (TAO_HAS_CORBALOC_PARSER == 1)
531 ++this->parser_names_count_
;
533 #if (TAO_HAS_CORBANAME_PARSER == 1)
534 ++this->parser_names_count_
;
536 #if (TAO_HAS_HTTP_PARSER == 1)
537 ++this->parser_names_count_
;
539 #if (TAO_HAS_MCAST_PARSER == 1)
540 ++this->parser_names_count_
;
542 ACE_NEW_RETURN (this->parser_names_
,
543 char *[this->parser_names_count_
],
546 CORBA::ULong index
= 0;
548 #if (TAO_HAS_DDL_PARSER == 1)
549 this->parser_names_
[index
] = CORBA::string_dup ("DLL_Parser");
553 #if (TAO_HAS_FILE_PARSER == 1)
554 this->parser_names_
[index
] = CORBA::string_dup ("FILE_Parser");
558 #if (TAO_HAS_CORBALOC_PARSER == 1)
559 this->parser_names_
[index
] = CORBA::string_dup ("CORBALOC_Parser");
563 #if (TAO_HAS_CORBANAME_PARSER == 1)
564 this->parser_names_
[index
] = CORBA::string_dup ("CORBANAME_Parser");
568 #if (TAO_HAS_MCAST_PARSER == 1)
569 this->parser_names_
[index
] = CORBA::string_dup ("MCAST_Parser");
573 #if (TAO_HAS_HTTP_PARSER == 1)
574 this->parser_names_
[index
] = CORBA::string_dup ("HTTP_Parser");
578 names
= this->parser_names_
;
580 number_of_names
= index
;
586 TAO_Default_Resource_Factory::add_to_ior_parser_names (const char *curarg
)
588 this->parser_names_
[this->index_
] = CORBA::string_dup (curarg
);
596 // This is virtual and protected...
598 TAO_Default_Resource_Factory::load_default_protocols ()
600 #if defined (TAO_HAS_IIOP) && (TAO_HAS_IIOP != 0)
601 // If the user did not list any protocols in her svc.conf file
602 // then default to TAO's basic protocols.
603 // You do *NOT* need modify this code to add your own protocol,
604 // instead simply add the following to your svc.conf file:
606 // dynamic PP_Factory Service_Object * LIB:_make_PP_Protocol_Factory() ""
607 // static Resource_Factory "-ORBProtocolFactory PP_Factory"
609 // where "PP_Factory" is the name of your protocol, i.e. the
610 // second argument passed to the ACE_STATIC_SVC_DEFINE macro:
612 // ACE_STATIC_SVC_DEFINE (PP_Protocol_Factory,
613 // ACE_TEXT ("PP_Factory"), ...)
615 // "PP_Protocol_Factory" is the name of your protocol factory
616 // class. A "_make_" is prepended to your protocol factory
617 // class name by the ACE_FACTORY_DECLARE macro. The resulting
618 // factory function "_make_PP_Protocol_Factory()" is what should
619 // be used in the "dynamic" line in your svc.conf file.
621 // LIB is the base name of the shared library that implements
622 // the protocol. The directory containing your library must be
623 // in your library search path, typically defined by the
624 // LD_LIBRARY_PATH environment variable on UNIX systems, and/or
625 // the `/etc/ld.so.conf' file on some UNIX systems. Remember to
626 // run "ldconfig" if you modify `/etc/ld.so.conf'.
628 if (TAO::details::load_protocol_factory
<TAO_IIOP_Protocol_Factory
> (
629 this->protocol_factories_
, "IIOP_Factory") == -1)
631 #endif /* TAO_HAS_IIOP && TAO_HAS_IIOP != 0 */
637 TAO_Default_Resource_Factory::init_protocol_factories ()
639 const TAO_ProtocolFactorySetItor end
= protocol_factories_
.end ();
640 TAO_ProtocolFactorySetItor factory
= protocol_factories_
.begin ();
644 return this->load_default_protocols ();
647 for (; factory
!= end
; ++factory
)
649 const ACE_CString
&name
= (*factory
)->protocol_name ();
650 (*factory
)->factory (
651 ACE_Dynamic_Service
<TAO_Protocol_Factory
>::instance (name
.c_str ()));
652 if ((*factory
)->factory () == nullptr)
654 TAOLIB_ERROR_RETURN ((LM_ERROR
,
655 ACE_TEXT ("TAO (%P|%t) - Unable to load ")
656 ACE_TEXT ("protocol <%C>, %p\n"),
662 if (TAO_debug_level
> 0)
664 TAOLIB_DEBUG ((LM_DEBUG
,
665 ACE_TEXT ("TAO (%P|%t) - Loaded protocol <%C>\n"),
674 TAO_Default_Resource_Factory::use_locked_data_blocks () const
676 return this->use_locked_data_blocks_
;
679 TAO_ProtocolFactorySet
*
680 TAO_Default_Resource_Factory::get_protocol_factories ()
682 return &protocol_factories_
;
685 TAO_Acceptor_Registry
*
686 TAO_Default_Resource_Factory::get_acceptor_registry ()
688 TAO_Acceptor_Registry
*ar
= nullptr;
691 TAO_Acceptor_Registry
,
697 TAO_Connector_Registry
*
698 TAO_Default_Resource_Factory::get_connector_registry ()
700 TAO_Connector_Registry
*cr
= nullptr;
703 TAO_Connector_Registry
,
709 #if (TAO_HAS_TIME_POLICY == 1)
710 TAO_Time_Policy_Manager
*
711 TAO_Default_Resource_Factory::time_policy_manager () const
713 // get time policy manager service
714 TAO_Time_Policy_Manager
* tpm
=
715 ACE_Dynamic_Service
<TAO_Time_Policy_Manager
>::instance (ACE_TEXT ("Time_Policy_Manager"));
719 TAOLIB_ERROR ((LM_ERROR
,
720 ACE_TEXT ("TAO (%P|%t) - TAO_Default_Resource_Factory::time_policy_manager: ")
721 ACE_TEXT ("FAILED to retrieve service Time_Policy_Manager\n")));
726 #endif /* TAO_HAS_TIME_POLICY */
729 TAO_Default_Resource_Factory::create_timer_queue () const
731 #if (TAO_HAS_TIME_POLICY == 1)
732 TAO_Time_Policy_Manager
* tpm
= this->time_policy_manager ();
735 return tpm
->create_timer_queue ();
737 #endif /* TAO_HAS_TIME_POLICY */
742 TAO_Default_Resource_Factory::destroy_timer_queue (ACE_Timer_Queue
*tmq
) const
744 #if (TAO_HAS_TIME_POLICY == 1)
745 TAO_Time_Policy_Manager
* tpm
= this->time_policy_manager ();
748 tpm
->destroy_timer_queue (tmq
);
750 #endif /* TAO_HAS_TIME_POLICY */
754 TAO_Default_Resource_Factory::allocate_reactor_impl () const
756 ACE_Reactor_Impl
*impl
= nullptr;
757 // get a timer queue (or not) from a possibly configured
759 TAO_RSF_Timer_Queue_Ptr
tmq (*this, this->create_timer_queue ());
760 ACE_NEW_RETURN (impl
,
761 ACE_TP_Reactor (ACE::max_handles (),
763 (ACE_Sig_Handler
*)nullptr,
765 this->reactor_mask_signals_
,
766 ACE_Select_Reactor_Token::LIFO
),
768 // safe to release timer queue
774 TAO_Default_Resource_Factory::get_reactor ()
776 ACE_Reactor
*reactor
= nullptr;
777 ACE_NEW_RETURN (reactor
,
778 ACE_Reactor (this->allocate_reactor_impl (), 1),
781 if (reactor
->initialized () == 0)
783 // backup timer queue
784 ACE_Timer_Queue
*tmq
= reactor
->timer_queue ();
788 // clean up timer queue in case it was created by time policy
789 this->destroy_timer_queue (tmq
);
792 this->dynamically_allocated_reactor_
= true;
798 TAO_Default_Resource_Factory::reclaim_reactor (ACE_Reactor
*reactor
)
800 if (this->dynamically_allocated_reactor_
)
802 // backup timer queue
803 ACE_Timer_Queue
*tmq
= reactor
->timer_queue ();
806 // clean up timer queue in case it was created by time policy
807 this->destroy_timer_queue (tmq
);
812 typedef ACE_Malloc
<ACE_LOCAL_MEMORY_POOL
,TAO_SYNCH_MUTEX
> LOCKED_MALLOC
;
813 typedef ACE_Allocator_Adapter
<LOCKED_MALLOC
> LOCKED_ALLOCATOR_POOL
;
814 typedef ACE_New_Allocator LOCKED_ALLOCATOR_NO_POOL
;
817 TAO_Default_Resource_Factory::use_local_memory_pool (bool flag
)
819 this->use_local_memory_pool_
= flag
;
821 if (this->output_cdr_allocator_type_
== DEFAULT
)
822 this->output_cdr_allocator_type_
= LOCAL_MEMORY_POOL
;
826 TAO_Default_Resource_Factory::input_cdr_dblock_allocator ()
828 ACE_Allocator
*allocator
= nullptr;
829 if (use_local_memory_pool_
)
831 ACE_NEW_RETURN (allocator
,
832 LOCKED_ALLOCATOR_POOL
,
837 ACE_NEW_RETURN (allocator
,
838 LOCKED_ALLOCATOR_NO_POOL
,
846 TAO_Default_Resource_Factory::input_cdr_buffer_allocator ()
848 ACE_Allocator
*allocator
= nullptr;
849 if (use_local_memory_pool_
)
851 ACE_NEW_RETURN (allocator
,
852 LOCKED_ALLOCATOR_POOL
,
857 ACE_NEW_RETURN (allocator
,
858 LOCKED_ALLOCATOR_NO_POOL
,
866 TAO_Default_Resource_Factory::input_cdr_msgblock_allocator ()
868 ACE_Allocator
*allocator
= nullptr;
869 if (use_local_memory_pool_
)
871 ACE_NEW_RETURN (allocator
,
872 LOCKED_ALLOCATOR_POOL
,
877 ACE_NEW_RETURN (allocator
,
878 LOCKED_ALLOCATOR_NO_POOL
,
886 TAO_Default_Resource_Factory::input_cdr_allocator_type_locked ()
892 TAO_Default_Resource_Factory::output_cdr_dblock_allocator ()
894 ACE_Allocator
*allocator
= nullptr;
895 if (use_local_memory_pool_
)
897 ACE_NEW_RETURN (allocator
,
898 LOCKED_ALLOCATOR_POOL
,
903 ACE_NEW_RETURN (allocator
,
904 LOCKED_ALLOCATOR_NO_POOL
,
912 TAO_Default_Resource_Factory::output_cdr_buffer_allocator ()
914 ACE_Allocator
*allocator
= nullptr;
916 switch (this->output_cdr_allocator_type_
)
918 case LOCAL_MEMORY_POOL
:
919 ACE_NEW_RETURN (allocator
,
920 LOCKED_ALLOCATOR_POOL
,
925 #if TAO_HAS_SENDFILE == 1
927 ACE_NEW_RETURN (allocator
,
932 #endif /* TAO_HAS_SENDFILE==1 */
936 ACE_NEW_RETURN (allocator
,
937 LOCKED_ALLOCATOR_NO_POOL
,
947 TAO_Default_Resource_Factory::output_cdr_msgblock_allocator ()
949 ACE_Allocator
*allocator
= nullptr;
950 if (use_local_memory_pool_
)
952 ACE_NEW_RETURN (allocator
,
953 LOCKED_ALLOCATOR_POOL
,
958 ACE_NEW_RETURN (allocator
,
959 LOCKED_ALLOCATOR_NO_POOL
,
967 TAO_Default_Resource_Factory::amh_response_handler_allocator ()
969 ACE_Allocator
*allocator
= nullptr;
970 if (use_local_memory_pool_
)
972 ACE_NEW_RETURN (allocator
,
973 LOCKED_ALLOCATOR_POOL
,
978 ACE_NEW_RETURN (allocator
,
979 LOCKED_ALLOCATOR_NO_POOL
,
987 TAO_Default_Resource_Factory::ami_response_handler_allocator ()
989 ACE_Allocator
*allocator
= nullptr;
990 if (use_local_memory_pool_
)
992 ACE_NEW_RETURN (allocator
,
993 LOCKED_ALLOCATOR_POOL
,
998 ACE_NEW_RETURN (allocator
,
999 LOCKED_ALLOCATOR_NO_POOL
,
1007 TAO_Default_Resource_Factory::cache_maximum () const
1009 return this->cache_maximum_
;
1013 TAO_Default_Resource_Factory::purge_percentage () const
1015 return this->purge_percentage_
;
1019 TAO_Default_Resource_Factory::max_muxed_connections () const
1021 return this->max_muxed_connections_
;
1026 TAO_Default_Resource_Factory::create_cached_connection_lock ()
1028 ACE_Lock
*the_lock
= nullptr;
1030 if (this->cached_connection_lock_type_
== TAO_NULL_LOCK
)
1031 ACE_NEW_RETURN (the_lock
,
1032 ACE_Lock_Adapter
<ACE_SYNCH_NULL_MUTEX
>,
1035 ACE_NEW_RETURN (the_lock
,
1036 ACE_Lock_Adapter
<TAO_SYNCH_MUTEX
>,
1043 TAO_Default_Resource_Factory::locked_transport_cache ()
1045 if (this->cached_connection_lock_type_
== TAO_NULL_LOCK
)
1051 TAO_Flushing_Strategy
*
1052 TAO_Default_Resource_Factory::create_flushing_strategy ()
1054 TAO_Flushing_Strategy
*strategy
= nullptr;
1055 if (this->flushing_strategy_type_
== TAO_LEADER_FOLLOWER_FLUSHING
)
1056 ACE_NEW_RETURN (strategy
,
1057 TAO_Leader_Follower_Flushing_Strategy
,
1059 else if (this->flushing_strategy_type_
== TAO_REACTIVE_FLUSHING
)
1060 ACE_NEW_RETURN (strategy
,
1061 TAO_Reactive_Flushing_Strategy
,
1064 ACE_NEW_RETURN (strategy
,
1065 TAO_Block_Flushing_Strategy
,
1070 TAO_Connection_Purging_Strategy
*
1071 TAO_Default_Resource_Factory::create_purging_strategy ()
1073 TAO_Connection_Purging_Strategy
*strategy
= nullptr;
1075 if (this->connection_purging_type_
== TAO_Resource_Factory::LRU
)
1077 ACE_NEW_RETURN (strategy
,
1078 TAO_LRU_Connection_Purging_Strategy (
1079 this->cache_maximum ()),
1084 TAOLIB_ERROR ((LM_ERROR
,
1085 ACE_TEXT ("TAO (%P|%t) - ")
1086 ACE_TEXT ("no usable purging strategy ")
1087 ACE_TEXT ("was found.\n")));
1094 TAO_Default_Resource_Factory::create_lf_strategy ()
1096 TAO_LF_Strategy
*strategy
= nullptr;
1098 ACE_NEW_RETURN (strategy
,
1099 TAO_LF_Strategy_Complete
,
1105 TAO_GIOP_Fragmentation_Strategy
*
1106 TAO_Default_Resource_Factory::create_fragmentation_strategy (
1107 TAO_Transport
* transport
,
1108 CORBA::ULong max_message_size
) const
1110 TAO_GIOP_Fragmentation_Strategy
* strategy
= nullptr;
1112 // Minimum GIOP message size is 24 (a multiple of 8):
1113 // 12 GIOP Message Header
1114 // 4 GIOP Fragment Header (request ID)
1115 // + 8 Smallest payload, including padding.
1118 static CORBA::ULong
const min_message_size
= 24;
1120 // GIOP fragments are supported in GIOP 1.1 and better, but TAO only
1121 // supports them in 1.2 or better since GIOP 1.1 fragments do not
1122 // have a fragment message header.
1123 if (transport
) // No transport. Cannot fragment.
1125 if (max_message_size
< min_message_size
1126 || (TAO_DEF_GIOP_MAJOR
== 1 && TAO_DEF_GIOP_MINOR
< 2))
1128 // No maximum was set by the user.
1129 ACE_NEW_RETURN (strategy
,
1130 TAO_Null_Fragmentation_Strategy
,
1136 ACE_NEW_RETURN (strategy
,
1137 TAO_On_Demand_Fragmentation_Strategy (
1148 TAO_Default_Resource_Factory::report_option_value_error (
1149 const ACE_TCHAR
* option_name
,
1150 const ACE_TCHAR
* option_value
)
1152 TAOLIB_DEBUG((LM_DEBUG
,
1153 ACE_TEXT ("TAO (%P|%t) - Default_Resource_Factory - unknown ")
1154 ACE_TEXT ("argument <%s> for <%s>\n"),
1155 option_value
, option_name
));
1159 TAO_Default_Resource_Factory::disable_factory ()
1161 this->factory_disabled_
= 1;
1162 if (this->options_processed_
)
1164 TAOLIB_DEBUG ((LM_WARNING
,
1165 ACE_TEXT ("TAO (%P|%t) - Warning: Resource_Factory options ignored\n")
1166 ACE_TEXT ("Default Resource Factory is disabled\n")));
1170 TAO_Codeset_Manager
*
1171 TAO_Default_Resource_Factory::codeset_manager()
1173 TAO_Codeset_Manager_Factory_Base
*factory
=
1174 ACE_Dynamic_Service
<TAO_Codeset_Manager_Factory_Base
>::instance ("TAO_Codeset");
1176 if (factory
== nullptr)
1178 if (TAO_debug_level
>= 2)
1179 TAOLIB_DEBUG ((LM_DEBUG
,
1180 ACE_TEXT ("TAO (%P|%t) - Default_Resource_Factory")
1181 ACE_TEXT (" - unable to find codeset manager factory.\n")));
1185 TAO_Codeset_Manager
* mgr
= factory
->create ();
1189 if (TAO_debug_level
>= 2)
1190 TAOLIB_DEBUG ((LM_INFO
,
1191 ACE_TEXT ("TAO (%P|%t) - Default_Resource_Factory")
1192 ACE_TEXT (" - unable to create codeset manager.\n")));
1197 std::unique_ptr
<TAO_Codeset_Manager
> safemgr (mgr
);
1199 if (TAO_debug_level
>= 1)
1200 TAOLIB_DEBUG ((LM_DEBUG
,
1201 ACE_TEXT ("TAO (%P|%t) - Default_Resource_Factory - codeset manager=%@\n"),
1204 this->char_codeset_parameters_
.apply_to (mgr
->char_codeset_descriptor());
1205 this->wchar_codeset_parameters_
.apply_to (mgr
->wchar_codeset_descriptor());
1207 return safemgr
.release ();
1210 TAO_Resource_Factory::Resource_Usage
1211 TAO_Default_Resource_Factory::resource_usage_strategy () const
1213 return this->resource_usage_strategy_
;
1217 TAO_Default_Resource_Factory::drop_replies_during_shutdown () const
1219 return this->drop_replies_
;
1222 // ****************************************************************
1224 ACE_STATIC_SVC_DEFINE (TAO_Default_Resource_Factory
,
1225 ACE_TEXT ("Resource_Factory"),
1227 &ACE_SVC_NAME (TAO_Default_Resource_Factory
),
1228 ACE_Service_Type::DELETE_THIS
1229 | ACE_Service_Type::DELETE_OBJ
,
1231 ACE_FACTORY_DEFINE (TAO
, TAO_Default_Resource_Factory
)
1233 TAO_END_VERSIONED_NAMESPACE_DECL