diff options
author | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-07-23 23:09:33 +0000 |
---|---|---|
committer | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-07-23 23:09:33 +0000 |
commit | 99cd3386785b2e0370df03ee2806c602cda7bb96 (patch) | |
tree | 7b076b875324185fb26864ac8a414c6c7f50dbf7 /TAO/tao | |
parent | deac13c18914ad557f4a974a0192e90cd413a694 (diff) | |
download | ATCD-99cd3386785b2e0370df03ee2806c602cda7bb96.tar.gz |
ChangeLogTag:Fri Jul 23 17:54:45 1999 Irfan Pyarali <irfan@cs.wustl.edu>
Diffstat (limited to 'TAO/tao')
-rw-r--r-- | TAO/tao/Acceptor_Impl.cpp | 68 | ||||
-rw-r--r-- | TAO/tao/Acceptor_Impl.h | 28 | ||||
-rw-r--r-- | TAO/tao/IIOP_Acceptor.cpp | 10 | ||||
-rw-r--r-- | TAO/tao/IIOP_Acceptor.h | 2 | ||||
-rw-r--r-- | TAO/tao/UIOP_Acceptor.cpp | 10 | ||||
-rw-r--r-- | TAO/tao/UIOP_Acceptor.h | 2 |
6 files changed, 117 insertions, 3 deletions
diff --git a/TAO/tao/Acceptor_Impl.cpp b/TAO/tao/Acceptor_Impl.cpp index c6933690369..94a21acc7bf 100644 --- a/TAO/tao/Acceptor_Impl.cpp +++ b/TAO/tao/Acceptor_Impl.cpp @@ -26,6 +26,7 @@ #include "tao/ORB_Core.h" #include "tao/Server_Strategy_Factory.h" +#include "tao/Connector_Registry.h" #if !defined(__ACE_INLINE__) #include "tao/Acceptor_Impl.i" @@ -33,6 +34,8 @@ ACE_RCSID(tao, Acceptor_Impl, "$Id$") +//////////////////////////////////////////////////////////////////////////////// + template <class SVC_HANDLER> TAO_Creation_Strategy<SVC_HANDLER>::TAO_Creation_Strategy (TAO_ORB_Core *orb_core) : orb_core_ (orb_core) @@ -50,13 +53,14 @@ TAO_Creation_Strategy<SVC_HANDLER>::make_svc_handler (SVC_HANDLER *&sh) return 0; } +//////////////////////////////////////////////////////////////////////////////// + template <class SVC_HANDLER> TAO_Concurrency_Strategy<SVC_HANDLER>::TAO_Concurrency_Strategy (TAO_ORB_Core *orb_core) : orb_core_ (orb_core) { } - template <class SVC_HANDLER> int TAO_Concurrency_Strategy<SVC_HANDLER>::activate_svc_handler (SVC_HANDLER *sh, void *arg) @@ -76,4 +80,66 @@ TAO_Concurrency_Strategy<SVC_HANDLER>::activate_svc_handler (SVC_HANDLER *sh, (sh, ACE_Event_Handler::READ_MASK); } +//////////////////////////////////////////////////////////////////////////////// + +template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> +TAO_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::TAO_Accept_Strategy (TAO_ORB_Core *orb_core) + : orb_core_ (orb_core) +{ +} + +template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int +TAO_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::open (const ACE_PEER_ACCEPTOR_ADDR &local_addr, + int restart) +{ + int result = ACCEPT_STRATEGY_BASE::open (local_addr, + restart); + + if (result == 0) + return result; + + // If the error occured due to the fact that the open handle limit + // was exhausted, then purge some "old" connections. + result = this->out_of_sockets_handler (); + if (result == -1) + return -1; + + // If we are able to purge, try again. + return ACCEPT_STRATEGY_BASE::open (local_addr, restart); +} + +template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int +TAO_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::accept_svc_handler (SVC_HANDLER *svc_handler) +{ + int result = ACCEPT_STRATEGY_BASE::accept_svc_handler (svc_handler); + + if (result == 0) + return result; + + // If the error occured due to the fact that the open handle limit + // was exhausted, then purge some "old" connections. + this->out_of_sockets_handler (); + + return result; +} + +template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int +TAO_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::out_of_sockets_handler (void) +{ + if (ACE::out_of_handles (errno)) + { + // Close some cached connections by explicitly purging the + // connection cache maintained by the connectors in the + // connector registry. + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "Purging connections from Connectors in Connector Registry...\n")); + + return this->orb_core_->connector_registry ()->purge_connections (); + } + + return -1; +} + +//////////////////////////////////////////////////////////////////////////////// + #endif /* TAO_ACCEPTOR_IMPL_C */ diff --git a/TAO/tao/Acceptor_Impl.h b/TAO/tao/Acceptor_Impl.h index 81bd0085389..063e05baf22 100644 --- a/TAO/tao/Acceptor_Impl.h +++ b/TAO/tao/Acceptor_Impl.h @@ -63,6 +63,34 @@ protected: // Pointer to the ORB Core. }; +template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> +class TAO_Accept_Strategy : public ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2> +{ +public: + + TAO_Accept_Strategy (TAO_ORB_Core *orb_core); + // Constructor. + + int open (const ACE_PEER_ACCEPTOR_ADDR &local_addr, + int restart = 0); + // Initialize the <peer_acceptor_> with <local_addr>. If the + // process runs out of handles, purge some "old" connections. + + int accept_svc_handler (SVC_HANDLER *svc_handler); + // Delegates to the <accept> method of the PEER_ACCEPTOR. If the + // process runs out of handles, purge some "old" connections. + +protected: + int out_of_sockets_handler (void); + // Handler which deals with purging "old" connections. + + typedef ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2> ACCEPT_STRATEGY_BASE; + // Base class. + + TAO_ORB_Core *orb_core_; + // Pointer to the ORB Core. +}; + #if defined(__ACE_INLINE__) #include "tao/Acceptor_Impl.i" #endif /* __ACE_INLINE__ */ diff --git a/TAO/tao/IIOP_Acceptor.cpp b/TAO/tao/IIOP_Acceptor.cpp index e4c940c0e26..a9d0df1dcdb 100644 --- a/TAO/tao/IIOP_Acceptor.cpp +++ b/TAO/tao/IIOP_Acceptor.cpp @@ -34,6 +34,7 @@ TAO_IIOP_Acceptor::TAO_IIOP_Acceptor (void) base_acceptor_ (), creation_strategy_ (0), concurrency_strategy_ (0), + accept_strategy_ (0), version_ (TAO_DEF_GIOP_MAJOR, TAO_DEF_GIOP_MINOR), orb_core_ (0) { @@ -43,6 +44,7 @@ TAO_IIOP_Acceptor::~TAO_IIOP_Acceptor (void) { delete this->creation_strategy_; delete this->concurrency_strategy_; + delete this->accept_strategy_; } // TODO = @@ -158,10 +160,14 @@ TAO_IIOP_Acceptor::open_i (TAO_ORB_Core* orb_core, TAO_IIOP_CONCURRENCY_STRATEGY (this->orb_core_), -1); + ACE_NEW_RETURN (this->accept_strategy_, + TAO_IIOP_ACCEPT_STRATEGY (this->orb_core_), + -1); + if (this->base_acceptor_.open (addr, this->orb_core_->reactor (), this->creation_strategy_, - 0, + this->accept_strategy_, this->concurrency_strategy_) == -1) { if (TAO_debug_level > 0) @@ -239,6 +245,7 @@ template class ACE_Concurrency_Strategy<TAO_IIOP_Server_Connection_Handler>; template class ACE_Scheduling_Strategy<TAO_IIOP_Server_Connection_Handler>; template class TAO_Creation_Strategy<TAO_IIOP_Server_Connection_Handler>; template class TAO_Concurrency_Strategy<TAO_IIOP_Server_Connection_Handler>; +template class TAO_Accept_Strategy<TAO_IIOP_Server_Connection_Handler, ACE_SOCK_ACCEPTOR>; #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) @@ -250,5 +257,6 @@ template class TAO_Concurrency_Strategy<TAO_IIOP_Server_Connection_Handler>; #pragma instantiate ACE_Scheduling_Strategy<TAO_IIOP_Server_Connection_Handler> #pragma instantiate TAO_Creation_Strategy<TAO_IIOP_Server_Connection_Handler> #pragma instantiate TAO_Concurrency_Strategy<TAO_IIOP_Server_Connection_Handler> +#pragma instantiate TAO_Accept_Strategy<TAO_IIOP_Server_Connection_Handler, ACE_SOCK_ACCEPTOR> #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/tao/IIOP_Acceptor.h b/TAO/tao/IIOP_Acceptor.h index 900dcc408bc..c45e93d7fbd 100644 --- a/TAO/tao/IIOP_Acceptor.h +++ b/TAO/tao/IIOP_Acceptor.h @@ -82,6 +82,7 @@ public: typedef ACE_Strategy_Acceptor<TAO_IIOP_Server_Connection_Handler, ACE_SOCK_ACCEPTOR> TAO_IIOP_BASE_ACCEPTOR; typedef TAO_Creation_Strategy<TAO_IIOP_Server_Connection_Handler> TAO_IIOP_CREATION_STRATEGY; typedef TAO_Concurrency_Strategy<TAO_IIOP_Server_Connection_Handler> TAO_IIOP_CONCURRENCY_STRATEGY; + typedef TAO_Accept_Strategy<TAO_IIOP_Server_Connection_Handler, ACE_SOCK_ACCEPTOR> TAO_IIOP_ACCEPT_STRATEGY; private: int open_i (TAO_ORB_Core* orb_core, @@ -94,6 +95,7 @@ private: TAO_IIOP_CREATION_STRATEGY *creation_strategy_; TAO_IIOP_CONCURRENCY_STRATEGY *concurrency_strategy_; + TAO_IIOP_ACCEPT_STRATEGY *accept_strategy_; // Acceptor strategies. ACE_INET_Addr address_; diff --git a/TAO/tao/UIOP_Acceptor.cpp b/TAO/tao/UIOP_Acceptor.cpp index 737f330a47e..b62478db05c 100644 --- a/TAO/tao/UIOP_Acceptor.cpp +++ b/TAO/tao/UIOP_Acceptor.cpp @@ -38,6 +38,7 @@ TAO_UIOP_Acceptor::TAO_UIOP_Acceptor (void) base_acceptor_ (), creation_strategy_ (0), concurrency_strategy_ (0), + accept_strategy_ (0), version_ (TAO_DEF_GIOP_MAJOR, TAO_DEF_GIOP_MINOR), orb_core_ (0), unlink_on_close_ (1) @@ -48,6 +49,7 @@ TAO_UIOP_Acceptor::~TAO_UIOP_Acceptor (void) { delete this->creation_strategy_; delete this->concurrency_strategy_; + delete this->accept_strategy_; } int @@ -163,6 +165,10 @@ TAO_UIOP_Acceptor::open_i (TAO_ORB_Core* orb_core, TAO_UIOP_CONCURRENCY_STRATEGY (this->orb_core_), -1); + ACE_NEW_RETURN (this->accept_strategy_, + TAO_UIOP_ACCEPT_STRATEGY (this->orb_core_), + -1); + ACE_UNIX_Addr addr; this->rendezvous_point (addr, rendezvous); @@ -170,7 +176,7 @@ TAO_UIOP_Acceptor::open_i (TAO_ORB_Core* orb_core, if (this->base_acceptor_.open (addr, this->orb_core_->reactor (), this->creation_strategy_, - 0, + this->accept_strategy_, this->concurrency_strategy_) == -1) { // Don't unlink an existing rendezvous point since it may be in @@ -256,6 +262,7 @@ template class ACE_Concurrency_Strategy<TAO_UIOP_Server_Connection_Handler>; template class ACE_Scheduling_Strategy<TAO_UIOP_Server_Connection_Handler>; template class TAO_Creation_Strategy<TAO_UIOP_Server_Connection_Handler>; template class TAO_Concurrency_Strategy<TAO_UIOP_Server_Connection_Handler>; +template class TAO_Accept_Strategy<TAO_UIOP_Server_Connection_Handler, ACE_LSOCK_ACCEPTOR>; #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) @@ -267,6 +274,7 @@ template class TAO_Concurrency_Strategy<TAO_UIOP_Server_Connection_Handler>; #pragma instantiate ACE_Scheduling_Strategy<TAO_UIOP_Server_Connection_Handler> #pragma instantiate TAO_Creation_Strategy<TAO_UIOP_Server_Connection_Handler> #pragma instantiate TAO_Concurrency_Strategy<TAO_UIOP_Server_Connection_Handler> +#pragma instantiate TAO_Accept_Strategy<TAO_UIOP_Server_Connection_Handler, ACE_LSOCK_ACCEPTOR> #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/tao/UIOP_Acceptor.h b/TAO/tao/UIOP_Acceptor.h index 5557c55e8dc..50ada984c60 100644 --- a/TAO/tao/UIOP_Acceptor.h +++ b/TAO/tao/UIOP_Acceptor.h @@ -82,6 +82,7 @@ public: typedef ACE_Strategy_Acceptor<TAO_UIOP_Server_Connection_Handler, ACE_LSOCK_ACCEPTOR> TAO_UIOP_BASE_ACCEPTOR; typedef TAO_Creation_Strategy<TAO_UIOP_Server_Connection_Handler> TAO_UIOP_CREATION_STRATEGY; typedef TAO_Concurrency_Strategy<TAO_UIOP_Server_Connection_Handler> TAO_UIOP_CONCURRENCY_STRATEGY; + typedef TAO_Accept_Strategy<TAO_UIOP_Server_Connection_Handler, ACE_LSOCK_ACCEPTOR> TAO_UIOP_ACCEPT_STRATEGY; private: int open_i (TAO_ORB_Core *orb_core, const char *rendezvous); @@ -97,6 +98,7 @@ private: TAO_UIOP_CREATION_STRATEGY *creation_strategy_; TAO_UIOP_CONCURRENCY_STRATEGY *concurrency_strategy_; + TAO_UIOP_ACCEPT_STRATEGY *accept_strategy_; // Acceptor strategies. TAO_GIOP_Version version_; |