diff options
author | bala <bala@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-05-23 10:56:16 +0000 |
---|---|---|
committer | bala <bala@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-05-23 10:56:16 +0000 |
commit | 54b5d7013eb54a35f363546f39d0c754e1d6da5e (patch) | |
tree | 62de5ed04a03da9964d849ac3a10ad05c0cf10d9 | |
parent | 1ec171123fa7d5548542694a53ef251aa89108a0 (diff) | |
download | ATCD-54b5d7013eb54a35f363546f39d0c754e1d6da5e.tar.gz |
ChangeLogTag:
-rw-r--r-- | TAO/ChangeLog | 62 | ||||
-rw-r--r-- | TAO/tao/Acceptor_Impl.cpp | 28 | ||||
-rw-r--r-- | TAO/tao/Connection_Handler.cpp | 8 | ||||
-rw-r--r-- | TAO/tao/Connection_Handler.h | 35 | ||||
-rw-r--r-- | TAO/tao/IIOP_Connection_Handler.cpp | 54 | ||||
-rw-r--r-- | TAO/tao/IIOP_Connection_Handler.h | 19 | ||||
-rw-r--r-- | TAO/tao/Makefile.bor | 1 | ||||
-rw-r--r-- | TAO/tao/Makefile.tao | 1 | ||||
-rw-r--r-- | TAO/tao/ObjectKey_Table.cpp | 1 | ||||
-rw-r--r-- | TAO/tao/Strategies/DIOP_Connection_Handler.cpp | 60 | ||||
-rw-r--r-- | TAO/tao/Strategies/DIOP_Connection_Handler.h | 21 | ||||
-rw-r--r-- | TAO/tao/Strategies/SCIOP_Connection_Handler.cpp | 57 | ||||
-rw-r--r-- | TAO/tao/Strategies/SCIOP_Connection_Handler.h | 27 | ||||
-rw-r--r-- | TAO/tao/Strategies/SHMIOP_Connection_Handler.cpp | 56 | ||||
-rw-r--r-- | TAO/tao/Strategies/SHMIOP_Connection_Handler.h | 22 | ||||
-rw-r--r-- | TAO/tao/Strategies/UIOP_Connection_Handler.cpp | 56 | ||||
-rw-r--r-- | TAO/tao/Strategies/UIOP_Connection_Handler.h | 28 | ||||
-rw-r--r-- | TAO/tao/TAO.dsp | 8 | ||||
-rw-r--r-- | TAO/tao/Thread_Per_Connection_Handler.cpp | 81 | ||||
-rw-r--r-- | TAO/tao/Thread_Per_Connection_Handler.h | 76 | ||||
-rw-r--r-- | TAO/tao/Transport.h | 4 |
21 files changed, 321 insertions, 384 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index 08514d9cd25..dc74519b965 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,65 @@ +Fri May 23 05:31:23 2003 Balachandran Natarajan <bala@dre.vanderbilt.edu> + + This checkin is for fixing a problem with thread-per-connection + strategy. If the client crahses during request processing on the + server side, the server cleans up both the transport and the + connection handler. This is in sync with what needs to happen + for the reactive strategy. + + But in the thread-per-connection strategy, the problem gets + exacerbated when the thread created for handling a new + connection starts to clean itself up once its exits the + *IOP_Connection_Handler::svc (). Since the handler is completely + deleted resource cleanup by ACE_Task crashes. + + This checkin basically decouples the thread-per-connection + handler and the handler that has protocol specific code. When + the client crahses only the protocol specific handler would get + cleaned up, leaving the thread-per-connection handler to be + cleaned when the thread created exits. + + * tao/Thread_Per_Connection_Handler.h: + * tao/Thread_Per_Connection_Handler.cpp: The new + thread-per-connection handler class. + + * tao/Acceptor_Impl.cpp (activate_svc_handler): If + thread-per-connection is enabled, create a thread-per-connection + handler object and pass the protocol specific handler to it. + + * tao/Connection_Handler.cpp (svc_i): Remove reference counting + since this is now performed by the thread-per-connection + handler. + + * tao/Transport.h: Provide privileged access to the + thread-per-connection-handler. + + * tao/Connection_Handler.h: Added a pure virtual open_handler () + method which would serve as a hook for the protocol specific + handler's open () call. + + * tao/IIOP_Connection_Handler.h: + * tao/IIOP_Connection_Handler.cpp: + * tao/Strategies/DIOP_Connection_Handler.h: + * tao/Strategies/DIOP_Connection_Handler.cpp: + * tao/Strategies/UIOP_Connection_Handler.h: + * tao/Strategies/UIOP_Connection_Handler.cpp: + * tao/Strategies/DIOP_Connection_Handler.h: + * tao/Strategies/DIOP_Connection_Handler.cpp: + * tao/Strategies/SHMIOP_Connection_Handler.h: + * tao/Strategies/SHMIOP_Connection_Handler.cpp: + * tao/Strategies/SCIOP_Connection_Handler.h: + * tao/Strategies/SCIOP_Connection_Handler.cpp: Implemented the + open_handler () hook method. Removed the svc () and activate () + calls since they should be taken care by the new + thread-per-connection-handler class. This also removes a bunch + of code duplication from within these classes. + + * tao/ObjectKey_Table.cpp (unbind_i): Removed a wrong comment. + + * tao/TAO.dsp: + * tao/Makefile.tao: + * tao/Makefile.bor: Added the new files for building. + Thu May 22 14:06:19 2003 Jeff Parsons <j.parsons@vanderbilt.edu> * TAO_IDL/util/utl_err.cpp: diff --git a/TAO/tao/Acceptor_Impl.cpp b/TAO/tao/Acceptor_Impl.cpp index 2307b027175..d290d2f4157 100644 --- a/TAO/tao/Acceptor_Impl.cpp +++ b/TAO/tao/Acceptor_Impl.cpp @@ -25,13 +25,14 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "tao/ORB_Core.h" -#include "tao/ORB_Table.h" -#include "tao/Server_Strategy_Factory.h" -#include "tao/Connector_Registry.h" -#include "tao/Transport_Cache_Manager.h" -#include "tao/Thread_Lane_Resources.h" -#include "tao/Transport.h" +#include "ORB_Core.h" +// #include "ORB_Table.h" +#include "Server_Strategy_Factory.h" +// #include "Connector_Registry.h" +#include "Transport_Cache_Manager.h" +#include "Thread_Lane_Resources.h" +#include "Transport.h" +#include "Thread_Per_Connection_Handler.h" #include "ace/Object_Manager.h" @@ -103,8 +104,17 @@ TAO_Concurrency_Strategy<SVC_HANDLER>::activate_svc_handler (SVC_HANDLER *sh, // thread-per-connection concurrency model if (f->activate_server_connections ()) - return sh->activate (f->server_connection_thread_flags (), - f->server_connection_thread_count ()); + { + TAO_Thread_Per_Connection_Handler *tpch = 0; + + ACE_NEW_RETURN (tpch, + TAO_Thread_Per_Connection_Handler (sh), + -1); + + return tpch->activate (f->server_connection_thread_flags (), + f->server_connection_thread_count ()); + } + // reactive concurrency model. We may want to register ourselves // with the reactor. Call the register handler on the transport. diff --git a/TAO/tao/Connection_Handler.cpp b/TAO/tao/Connection_Handler.cpp index f0a3b8edf76..b70d618860b 100644 --- a/TAO/tao/Connection_Handler.cpp +++ b/TAO/tao/Connection_Handler.cpp @@ -113,12 +113,6 @@ TAO_Connection_Handler::svc_i (void) TAO_Resume_Handle rh (this->orb_core_, ACE_INVALID_HANDLE); - - // Increase the reference count before we process any requests - // - // REFCNT: Matches decr_refcount() in this function after the loop. - (void) this->incr_refcount (); - // We exit of the loop if // - If the ORB core is shutdown by another thread // - Or if the transport is null. This could happen if an error @@ -154,8 +148,6 @@ TAO_Connection_Handler::svc_i (void) "TAO (%P|%t) - Connection_Handler::svc_i - " "loop <%d>\n", current_timeout.msec ())); } - // REFCNT: Matches incr_refcount() before the loop... - (void) this->decr_refcount (); if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG, diff --git a/TAO/tao/Connection_Handler.h b/TAO/tao/Connection_Handler.h index 8b0503d206c..6401e86aca6 100644 --- a/TAO/tao/Connection_Handler.h +++ b/TAO/tao/Connection_Handler.h @@ -57,15 +57,6 @@ public: /// Set the underlying transport object void transport (TAO_Transport* transport); -# if 0 - /// NOTE: NO longer used - /// Did the process of non-blocking connection initialization - /// complete? - int is_connect_complete (void) const; - - /// Was the non-blocking connection initialization successful? - int is_connect_successful (void) const; -#endif /*if 0*/ /// Is the state final? int is_finalized (void); @@ -93,6 +84,16 @@ public: /// reference to this object can call the event handler methods. virtual int handle_input (ACE_HANDLE fd) = 0; + /// This method is invoked from the svc () method of the Svc_Handler + /// Object. + int svc_i (void); + + /// A open () hook + /** + * See Thread_Per_Connection_Handler for a use case + */ + virtual int open_handler (void *) = 0; + protected: /// Destructor @@ -113,21 +114,6 @@ protected: int snd_size, int rcv_size); - /// This method is invoked from the svc () method of the Svc_Handler - /// Object. - int svc_i (void); - - /**** - * Not sure where they are defined and used.. Looks legacy. - * - * Increment and decrement the number of upcalls that have gone - * this handler. Returns the upcall count. The calls are - * safe.. - * int incr_pending_upcalls (void); - * int decr_pending_upcalls (void); - * int pending_upcalls (void) const; - */ - //@{ /** * @name Helper methods for Event_Handler-based derived classes. @@ -173,6 +159,7 @@ protected: virtual void pos_io_hook (int & return_value); //@} + private: /// Pointer to the TAO_ORB_Core TAO_ORB_Core *orb_core_; diff --git a/TAO/tao/IIOP_Connection_Handler.cpp b/TAO/tao/IIOP_Connection_Handler.cpp index 00e341b6079..9ea68fc555f 100644 --- a/TAO/tao/IIOP_Connection_Handler.cpp +++ b/TAO/tao/IIOP_Connection_Handler.cpp @@ -72,6 +72,13 @@ TAO_IIOP_Connection_Handler::~TAO_IIOP_Connection_Handler (void) { } + +int +TAO_IIOP_Connection_Handler::open_handler (void *v) +{ + return this->open (v); +} + int TAO_IIOP_Connection_Handler::open (void*) { @@ -151,56 +158,9 @@ TAO_IIOP_Connection_Handler::open (void*) return 0; } -int -TAO_IIOP_Connection_Handler::activate (long flags, - int n_threads, - int force_active, - long priority, - int grp_id, - ACE_Task_Base *task, - ACE_hthread_t thread_handles[], - void *stack[], - size_t stack_size[], - ACE_thread_t thread_names[]) -{ - if (TAO_debug_level) - ACE_DEBUG ((LM_DEBUG, - ACE_LIB_TEXT ("TAO (%P|%t) - IIOP_Connection_Handler::") - ACE_LIB_TEXT ("activate %d threads, flags = %d\n"), - n_threads, - flags, - THR_BOUND)); - // Set the id in the transport now that we're active. - // Use C-style cast b/c otherwise we get warnings on lots of compilers - this->transport ()->id ((size_t) this->get_handle ()); - - return TAO_IIOP_SVC_HANDLER::activate (flags, - n_threads, - force_active, - priority, - grp_id, - task, - thread_handles, - stack, - stack_size, - thread_names); -} -int -TAO_IIOP_Connection_Handler::svc (void) -{ - // This method is called when an instance is "activated", i.e., - // turned into an active object. Presumably, activation spawns a - // thread with this method as the "worker function". - // Clear the non-blocking mode here - ACE_Flag_Manip::clr_flags (this->get_handle (), - ACE_NONBLOCK); - - // Call the implementation here - return this->svc_i (); -} int TAO_IIOP_Connection_Handler::resume_handler (void) diff --git a/TAO/tao/IIOP_Connection_Handler.h b/TAO/tao/IIOP_Connection_Handler.h index bd157821fe9..fe7d26c3881 100644 --- a/TAO/tao/IIOP_Connection_Handler.h +++ b/TAO/tao/IIOP_Connection_Handler.h @@ -99,24 +99,6 @@ public: /// connected. Argument is unused. virtual int open (void *); - - /// = Active object activation method. - virtual int activate (long flags = THR_NEW_LWP, - int n_threads = 1, - int force_active = 0, - long priority = ACE_DEFAULT_THREAD_PRIORITY, - int grp_id = -1, - ACE_Task_Base *task = 0, - ACE_hthread_t thread_handles[] = 0, - void *stack[] = 0, - size_t stack_size[] = 0, - ACE_thread_t thread_names[] = 0); - - - /// Only used when the handler is turned into an active object by - /// calling <activate>. This serves as the event loop in such cases. - virtual int svc (void); - //@{ /** @name Event Handler overloads */ @@ -147,6 +129,7 @@ public: int recv_buffer_size, int no_delay, int enable_network_priority); + virtual int open_handler (void *); protected: diff --git a/TAO/tao/Makefile.bor b/TAO/tao/Makefile.bor index ab99e8e9d56..55003ad884f 100644 --- a/TAO/tao/Makefile.bor +++ b/TAO/tao/Makefile.bor @@ -61,6 +61,7 @@ OBJFILES = \ $(OBJDIR)\Connection_Purging_Strategy.obj \ $(OBJDIR)\Connection_Handler.obj \ $(OBJDIR)\Notify_Handler.obj \ + $(OBJDIR)\Thread_Per_Connection_Handler.obj \ $(OBJDIR)\Connector_Impl.obj \ $(OBJDIR)\Connector_Registry.obj \ $(OBJDIR)\CurrentC.obj \ diff --git a/TAO/tao/Makefile.tao b/TAO/tao/Makefile.tao index d364774a214..2a0a35bfff1 100644 --- a/TAO/tao/Makefile.tao +++ b/TAO/tao/Makefile.tao @@ -98,6 +98,7 @@ PLUGGABLE_PROTOCOLS_FILES = \ Endpoint \ Connector_Registry \ Connection_Handler \ + Thread_Per_Connection_Handler \ Acceptor_Registry \ Protocol_Factory \ Acceptor_Filter \ diff --git a/TAO/tao/ObjectKey_Table.cpp b/TAO/tao/ObjectKey_Table.cpp index 5798a886575..ddbb3673181 100644 --- a/TAO/tao/ObjectKey_Table.cpp +++ b/TAO/tao/ObjectKey_Table.cpp @@ -162,7 +162,6 @@ TAO::ObjectKey_Table::unbind_i (TAO::Refcounted_ObjectKey *&key_new) } #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) - // Instantiations for the Hash Map template class ACE_RB_Tree <TAO::ObjectKey, TAO::Refcounted_ObjectKey, TAO::Less_Than_ObjectKey, diff --git a/TAO/tao/Strategies/DIOP_Connection_Handler.cpp b/TAO/tao/Strategies/DIOP_Connection_Handler.cpp index e29535ba633..21be6692f27 100644 --- a/TAO/tao/Strategies/DIOP_Connection_Handler.cpp +++ b/TAO/tao/Strategies/DIOP_Connection_Handler.cpp @@ -104,6 +104,11 @@ TAO_DIOP_Connection_Handler::dgram (void) } // DIOP Additions - End +int +TAO_DIOP_Connection_Handler::open_handler (void *v) +{ + return this->open (v); +} int TAO_DIOP_Connection_Handler::open (void*) @@ -147,61 +152,6 @@ TAO_DIOP_Connection_Handler::open_server (void) } int -TAO_DIOP_Connection_Handler::activate (long flags, - int n_threads, - int force_active, - long priority, - int grp_id, - ACE_Task_Base *task, - ACE_hthread_t thread_handles[], - void *stack[], - size_t stack_size[], - ACE_thread_t thread_names[]) -{ - if (TAO_debug_level) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("TAO (%P|%t) DIOP_Connection_Handler::activate %d ") - ACE_TEXT ("threads, flags = %d\n"), - n_threads, - flags, - THR_BOUND)); - // @@ Michael: I believe we do not need active service handlers right now. - // @@ Frank: Not disabled yet... - - // Set the id in the transport now that we're active. - this->transport ()->id ((size_t) this->get_handle ()); - - return TAO_DIOP_SVC_HANDLER::activate (flags, - n_threads, - force_active, - priority, - grp_id, - task, - thread_handles, - stack, - stack_size, - thread_names); -} - -int -TAO_DIOP_Connection_Handler::svc (void) -{ - // @@ Michael: I believe we do not need active service handlers right now. - // @@ Frank: Not yet... - - // This method is called when an instance is "activated", i.e., - // turned into an active object. Presumably, activation spawns a - // thread with this method as the "worker function". - - // Clear the non-blocking mode here - ACE_Flag_Manip::clr_flags (this->get_handle (), - ACE_NONBLOCK); - - // Call the implementation here - return this->svc_i (); -} - -int TAO_DIOP_Connection_Handler::resume_handler (void) { return ACE_Event_Handler::ACE_APPLICATION_RESUMES_HANDLER; diff --git a/TAO/tao/Strategies/DIOP_Connection_Handler.h b/TAO/tao/Strategies/DIOP_Connection_Handler.h index 7a021b3cee0..4fbf5155a7a 100644 --- a/TAO/tao/Strategies/DIOP_Connection_Handler.h +++ b/TAO/tao/Strategies/DIOP_Connection_Handler.h @@ -95,21 +95,12 @@ public: // @@ Frank: Similar to open, but called on server virtual int open_server (void); - /// Active object activation method. - virtual int activate (long flags = THR_NEW_LWP, - int n_threads = 1, - int force_active = 0, - long priority = ACE_DEFAULT_THREAD_PRIORITY, - int grp_id = -1, - ACE_Task_Base *task = 0, - ACE_hthread_t thread_handles[] = 0, - void *stack[] = 0, - size_t stack_size[] = 0, - ACE_thread_t thread_names[] = 0); - - /// Only used when the handler is turned into an active object by - /// calling <activate>. This serves as the event loop in such cases. - virtual int svc (void); + //@{ + /** + * Connection_Handler overloads + */ + virtual int open_handler (void *); + //@} //@{ /** @name Event Handler overloads diff --git a/TAO/tao/Strategies/SCIOP_Connection_Handler.cpp b/TAO/tao/Strategies/SCIOP_Connection_Handler.cpp index 04f77355531..187dae6aaa6 100644 --- a/TAO/tao/Strategies/SCIOP_Connection_Handler.cpp +++ b/TAO/tao/Strategies/SCIOP_Connection_Handler.cpp @@ -76,6 +76,12 @@ TAO_SCIOP_Connection_Handler::~TAO_SCIOP_Connection_Handler (void) } int +TAO_SCIOP_Connection_Handler::open_handler (void *v) +{ + return this->open (v); +} + +int TAO_SCIOP_Connection_Handler::open (void*) { if (this->set_socket_option (this->peer (), @@ -154,57 +160,6 @@ TAO_SCIOP_Connection_Handler::open (void*) } int -TAO_SCIOP_Connection_Handler::activate (long flags, - int n_threads, - int force_active, - long priority, - int grp_id, - ACE_Task_Base *task, - ACE_hthread_t thread_handles[], - void *stack[], - size_t stack_size[], - ACE_thread_t thread_names[]) -{ - if (TAO_debug_level) - ACE_DEBUG ((LM_DEBUG, - ACE_LIB_TEXT ("TAO (%P|%t) - SCIOP_Connection_Handler::"), - ACE_LIB_TEXT ("activate %d threads, flags = %d\n"), - n_threads, - flags, - THR_BOUND)); - - // Set the id in the transport now that we're active. - // Use C-style cast b/c otherwise we get warnings on lots of compilers - this->transport ()->id ((size_t) this->get_handle ()); - - return TAO_SCIOP_SVC_HANDLER::activate (flags, - n_threads, - force_active, - priority, - grp_id, - task, - thread_handles, - stack, - stack_size, - thread_names); -} - -int -TAO_SCIOP_Connection_Handler::svc (void) -{ - // This method is called when an instance is "activated", i.e., - // turned into an active object. Presumably, activation spawns a - // thread with this method as the "worker function". - - // Clear the non-blocking mode here - ACE_Flag_Manip::clr_flags (this->get_handle (), - ACE_NONBLOCK); - - // Call the implementation here - return this->svc_i (); -} - -int TAO_SCIOP_Connection_Handler::resume_handler (void) { return ACE_Event_Handler::ACE_APPLICATION_RESUMES_HANDLER; diff --git a/TAO/tao/Strategies/SCIOP_Connection_Handler.h b/TAO/tao/Strategies/SCIOP_Connection_Handler.h index e19fd9a151b..a54e7d1fa33 100644 --- a/TAO/tao/Strategies/SCIOP_Connection_Handler.h +++ b/TAO/tao/Strategies/SCIOP_Connection_Handler.h @@ -113,27 +113,12 @@ public: /// Destructor. ~TAO_SCIOP_Connection_Handler (void); - /// Called by the <Strategy_Acceptor> when the handler is completely - /// connected. Argument is unused. - virtual int open (void *); - - - /// = Active object activation method. - virtual int activate (long flags = THR_NEW_LWP, - int n_threads = 1, - int force_active = 0, - long priority = ACE_DEFAULT_THREAD_PRIORITY, - int grp_id = -1, - ACE_Task_Base *task = 0, - ACE_hthread_t thread_handles[] = 0, - void *stack[] = 0, - size_t stack_size[] = 0, - ACE_thread_t thread_names[] = 0); - - - /// Only used when the handler is turned into an active object by - /// calling <activate>. This serves as the event loop in such cases. - virtual int svc (void); + //@{ + /** + * Connection_Handler overloads + */ + virtual int open_handler (void *); + //@} //@{ /** @name Event Handler overloads diff --git a/TAO/tao/Strategies/SHMIOP_Connection_Handler.cpp b/TAO/tao/Strategies/SHMIOP_Connection_Handler.cpp index eb6320dfbd4..6ff58729342 100644 --- a/TAO/tao/Strategies/SHMIOP_Connection_Handler.cpp +++ b/TAO/tao/Strategies/SHMIOP_Connection_Handler.cpp @@ -56,6 +56,12 @@ TAO_SHMIOP_Connection_Handler::~TAO_SHMIOP_Connection_Handler (void) } int +TAO_SHMIOP_Connection_Handler::open_handler (void *v) +{ + return this->open (v); +} + +int TAO_SHMIOP_Connection_Handler::open (void*) { if (this->set_socket_option (this->peer (), @@ -113,56 +119,6 @@ TAO_SHMIOP_Connection_Handler::open (void*) } int -TAO_SHMIOP_Connection_Handler::activate (long flags, - int n_threads, - int force_active, - long priority, - int grp_id, - ACE_Task_Base *task, - ACE_hthread_t thread_handles[], - void *stack[], - size_t stack_size[], - ACE_thread_t thread_names[]) -{ - if (TAO_debug_level) - ACE_DEBUG ((LM_DEBUG, - ACE_LIB_TEXT ("TAO (%P|%t) SHMIOP_Connection_Handler::activate %d ") - ACE_LIB_TEXT ("threads, flags = %d\n"), - n_threads, - flags, - THR_BOUND)); - - // Set the id in the transport now that we're active. - this->transport ()->id ((size_t) this->get_handle ()); - - return TAO_SHMIOP_SVC_HANDLER::activate (flags, - n_threads, - force_active, - priority, - grp_id, - task, - thread_handles, - stack, - stack_size, - thread_names); -} - -int -TAO_SHMIOP_Connection_Handler::svc (void) -{ - // This method is called when an instance is "activated", i.e., - // turned into an active object. Presumably, activation spawns a - // thread with this method as the "worker function". - - // Clear the non-blocking mode here - ACE_Flag_Manip::clr_flags (this->get_handle (), - ACE_NONBLOCK); - - // Call the implementation here - return this->svc_i (); -} - -int TAO_SHMIOP_Connection_Handler::resume_handler (void) { return ACE_Event_Handler::ACE_APPLICATION_RESUMES_HANDLER; diff --git a/TAO/tao/Strategies/SHMIOP_Connection_Handler.h b/TAO/tao/Strategies/SHMIOP_Connection_Handler.h index 6995d830a25..fd1d046a43b 100644 --- a/TAO/tao/Strategies/SHMIOP_Connection_Handler.h +++ b/TAO/tao/Strategies/SHMIOP_Connection_Handler.h @@ -64,22 +64,12 @@ public: /// connected. Argument is unused. virtual int open (void *); - - /// Active object activation method. - virtual int activate (long flags = THR_NEW_LWP, - int n_threads = 1, - int force_active = 0, - long priority = ACE_DEFAULT_THREAD_PRIORITY, - int grp_id = -1, - ACE_Task_Base *task = 0, - ACE_hthread_t thread_handles[] = 0, - void *stack[] = 0, - size_t stack_size[] = 0, - ACE_thread_t thread_names[] = 0); - - /// Only used when the handler is turned into an active object by - /// calling <activate>. This serves as the event loop in such cases. - virtual int svc (void); + //@{ + /** + * Connection_Handler overloads + */ + virtual int open_handler (void *); + //@} //@{ /** @name Event Handler overloads diff --git a/TAO/tao/Strategies/UIOP_Connection_Handler.cpp b/TAO/tao/Strategies/UIOP_Connection_Handler.cpp index bff3c4dc6bc..ca1b2f1b95a 100644 --- a/TAO/tao/Strategies/UIOP_Connection_Handler.cpp +++ b/TAO/tao/Strategies/UIOP_Connection_Handler.cpp @@ -61,6 +61,12 @@ TAO_UIOP_Connection_Handler::~TAO_UIOP_Connection_Handler (void) } int +TAO_UIOP_Connection_Handler::open_handler (void *v) +{ + return this->open (v); +} + +int TAO_UIOP_Connection_Handler::open (void*) { if (this->set_socket_option (this->peer (), @@ -96,56 +102,6 @@ TAO_UIOP_Connection_Handler::open (void*) } int -TAO_UIOP_Connection_Handler::activate (long flags, - int n_threads, - int force_active, - long priority, - int grp_id, - ACE_Task_Base *task, - ACE_hthread_t thread_handles[], - void *stack[], - size_t stack_size[], - ACE_thread_t thread_names[]) -{ - if (TAO_debug_level) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("TAO (%P|%t) UIOP_Connection_Handler::activate %d ") - ACE_TEXT ("threads, flags = %d\n"), - n_threads, - flags, - THR_BOUND)); - - // Set the id in the transport now that we're active. - this->transport ()->id ((size_t) this->get_handle ()); - - return TAO_UIOP_SVC_HANDLER::activate (flags, - n_threads, - force_active, - priority, - grp_id, - task, - thread_handles, - stack, - stack_size, - thread_names); -} - -int -TAO_UIOP_Connection_Handler::svc (void) -{ - // This method is called when an instance is "activated", i.e., - // turned into an active object. Presumably, activation spawns a - // thread with this method as the "worker function". - - // Clear the non-blocking mode here - ACE_Flag_Manip::clr_flags (this->get_handle (), - ACE_NONBLOCK); - - // Call the implementation here - return this->svc_i (); -} - -int TAO_UIOP_Connection_Handler::resume_handler (void) { return ACE_Event_Handler::ACE_APPLICATION_RESUMES_HANDLER; diff --git a/TAO/tao/Strategies/UIOP_Connection_Handler.h b/TAO/tao/Strategies/UIOP_Connection_Handler.h index 4a86e13dd64..1d5e1e212c5 100644 --- a/TAO/tao/Strategies/UIOP_Connection_Handler.h +++ b/TAO/tao/Strategies/UIOP_Connection_Handler.h @@ -79,30 +79,18 @@ public: /// Destructor. ~TAO_UIOP_Connection_Handler (void); - /// Called by the <Strategy_Acceptor> when the handler is completely - /// connected. Argument is unused. - virtual int open (void *); - - - /// Active object activation method. - virtual int activate (long flags = THR_NEW_LWP, - int n_threads = 1, - int force_active = 0, - long priority = ACE_DEFAULT_THREAD_PRIORITY, - int grp_id = -1, - ACE_Task_Base *task = 0, - ACE_hthread_t thread_handles[] = 0, - void *stack[] = 0, - size_t stack_size[] = 0, - ACE_thread_t thread_names[] = 0); - /// Only used when the handler is turned into an active object by - /// calling <activate>. This serves as the event loop in such cases. - virtual int svc (void); + //@{ + /** + * Connection_Handler overloads + */ + virtual int open_handler (void *); + //@} //@{ /** @name Event Handler overloads */ + virtual int open (void *); virtual int resume_handler (void); virtual int close_connection (void); virtual int handle_input (ACE_HANDLE); @@ -110,9 +98,11 @@ public: virtual int handle_close (ACE_HANDLE, ACE_Reactor_Mask); //@} + /// Add ourselves to Cache. int add_transport_to_cache (void); + protected: //@{ diff --git a/TAO/tao/TAO.dsp b/TAO/tao/TAO.dsp index 659e59850d3..52dd5ec14a5 100644 --- a/TAO/tao/TAO.dsp +++ b/TAO/tao/TAO.dsp @@ -934,6 +934,10 @@ SOURCE=.\Thread_Lane_Resources_Manager.cpp # End Source File
# Begin Source File
+SOURCE=.\Thread_Per_Connection_Handler.cpp
+# End Source File
+# Begin Source File
+
SOURCE=.\TimeBaseC.cpp
# ADD CPP /GR
# End Source File
@@ -1852,6 +1856,10 @@ SOURCE=.\Thread_Lane_Resources_Manager.h # End Source File
# Begin Source File
+SOURCE=.\Thread_Per_Connection_Handler.h
+# End Source File
+# Begin Source File
+
SOURCE=.\TimeBaseC.h
# End Source File
# Begin Source File
diff --git a/TAO/tao/Thread_Per_Connection_Handler.cpp b/TAO/tao/Thread_Per_Connection_Handler.cpp new file mode 100644 index 00000000000..d69e6dcf0df --- /dev/null +++ b/TAO/tao/Thread_Per_Connection_Handler.cpp @@ -0,0 +1,81 @@ +//$Id$ +#include "Thread_Per_Connection_Handler.h" +#include "Connection_Handler.h" +#include "debug.h" +#include "ace/Flag_Manip.h" +#include "Transport.h" + +ACE_RCSID (tao, + Thread_Per_Connection_Handler, + "$Id$") + +TAO_Thread_Per_Connection_Handler::TAO_Thread_Per_Connection_Handler ( + TAO_Connection_Handler *ch) + : ch_ (ch) +{ + // REFCNT: Matches decr_refcount() in the destructor. + (void) this->ch_->incr_refcount (); +} + +TAO_Thread_Per_Connection_Handler::~TAO_Thread_Per_Connection_Handler (void) +{ + // REFCNT: Matches incr_refcount() in the constructor. + (void) this->ch_->decr_refcount (); +} + +int +TAO_Thread_Per_Connection_Handler::activate (long flags, + int n_threads, + int force_active, + long priority, + int grp_id, + ACE_Task_Base *task, + ACE_hthread_t thread_handles[], + void *stack[], + size_t stack_size[], + ACE_thread_t thread_names[]) +{ + if (TAO_debug_level) + ACE_DEBUG ((LM_DEBUG, + ACE_LIB_TEXT ("TAO (%P|%t) - IIOP_Connection_Handler::") + ACE_LIB_TEXT ("activate %d threads, flags = %d\n"), + n_threads, + flags, + THR_BOUND)); + + return TAO_TPC_BASE::activate (flags, + n_threads, + force_active, + priority, + grp_id, + task, + thread_handles, + stack, + stack_size, + thread_names); +} + +int +TAO_Thread_Per_Connection_Handler::svc (void) +{ + ACE_Flag_Manip::clr_flags ( + this->ch_->transport ()->event_handler_i ()->get_handle (), + ACE_NONBLOCK); + + // Call the implementation here + return this->ch_->svc_i (); +} + +int +TAO_Thread_Per_Connection_Handler::open (void*v) +{ + return this->ch_->open_handler (v); +} + +int +TAO_Thread_Per_Connection_Handler::close (u_long) +{ + delete this; + + return 0; +} diff --git a/TAO/tao/Thread_Per_Connection_Handler.h b/TAO/tao/Thread_Per_Connection_Handler.h new file mode 100644 index 00000000000..ea1f7704b89 --- /dev/null +++ b/TAO/tao/Thread_Per_Connection_Handler.h @@ -0,0 +1,76 @@ +// This may look like C, but it's really -*- C++ -*- + +//============================================================================= +/** + * @file Thread_Per_Connection_Handler.h + * + * $Id$ + * + * Definition of a connection handler for the thread-per-connection + * strategy. + * + * @author Balachandran Natarajan <bala@dre.vanderbilt.edu> + */ +//============================================================================= + +#ifndef TAO_THREAD_PER_CONNECTION_HANDLER_H +#define TAO_THREAD_PER_CONNECTION_HANDLER_H +#include "ace/pre.h" + +#include "TAO_Export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Task_T.h" + +class TAO_Connection_Handler; + +typedef ACE_Task<ACE_NULL_SYNCH> TAO_TPC_BASE; + +/** + * @class TAO_Thread_Per_Connection_Handler + * + * @brief Definition for the thread-per-connection strategy. + * + * This object acts as an active object, encapsulating the protocol + * specific handler which the active thread uses to process incoming + * messages. + * + */ +class TAO_Export TAO_Thread_Per_Connection_Handler : public TAO_TPC_BASE +{ +public: + TAO_Thread_Per_Connection_Handler (TAO_Connection_Handler *ch); + + ~TAO_Thread_Per_Connection_Handler (void); + + /// = Active object activation method. + virtual int activate (long flags = THR_NEW_LWP, + int n_threads = 1, + int force_active = 0, + long priority = ACE_DEFAULT_THREAD_PRIORITY, + int grp_id = -1, + ACE_Task_Base *task = 0, + ACE_hthread_t thread_handles[] = 0, + void *stack[] = 0, + size_t stack_size[] = 0, + ACE_thread_t thread_names[] = 0); + + /// Template hook method that the thread uses... + /** + * Please see the documentation in ace/Task.h for details. + */ + virtual int svc (void); + virtual int open (void *); + virtual int close (u_long); + +private: + /// Pointer to protocsol specific code that does the bunch of the + /// job. + TAO_Connection_Handler *ch_; +}; + +#include "ace/post.h" +#endif /*TAO_THREAD_PER_CONNECTION_HANDLER_H*/ diff --git a/TAO/tao/Transport.h b/TAO/tao/Transport.h index 6551171ead8..e78fa5ea664 100644 --- a/TAO/tao/Transport.h +++ b/TAO/tao/Transport.h @@ -828,6 +828,10 @@ private: friend class TAO_Reactive_Flushing_Strategy; friend class TAO_Leader_Follower_Flushing_Strategy; + /// Needs priveleged access to + /// event_handler_i () + friend class TAO_Thread_Per_Connection_Handler; + /// Schedule handle_output() callbacks int schedule_output_i (void); |