2 //=============================================================================
4 * @file ImR_Activator_i.h
6 * @author Priyanka Gontla <gontla_p@ociweb.com>
7 * @author Darrell Brunsch <brunsch@cs.wustl.edu>
9 //=============================================================================
11 #ifndef IMR_ACTIVATOR_I_H
12 #define IMR_ACTIVATOR_I_H
14 #include "activator_export.h"
16 #include "ImR_ActivatorS.h"
17 #include "ImR_LocatorC.h"
19 #include "ace/Process_Manager.h"
20 #include "ace/Hash_Map_Manager.h"
21 #include "ace/Null_Mutex.h"
22 #include "ace/SString.h"
23 #if defined (ACE_WIN32)
24 # include "ace/Task.h"
25 #endif /* ACE_WIN32 */
27 #if !defined (ACE_LACKS_PRAGMA_ONCE)
29 #endif /* ACE_LACKS_PRAGMA_ONCE */
31 class Activator_Options
;
33 // ace/Functor.h doesn't provide functors for every built in integer type.
34 // Depending on the platform and what pid_t maps to, the functors may be missing.
37 unsigned long operator () (pid_t t
) const
43 struct ACE_Equal_To_pid_t
45 int operator () (const pid_t lhs
, const pid_t rhs
) const
51 #if (ACE_SIZEOF_VOID_P == 8)
52 typedef ACE_INT64 Act_token_type
;
54 typedef ACE_INT32 Act_token_type
;
57 #if defined (ACE_WIN32)
58 class Active_Pid_Setter
;
60 class Activator_Export Watchdog
: public ACE_Task_Base
63 Watchdog (ACE_Process_Manager
& procman
);
69 ACE_Process_Manager
&procman_
;
71 #endif /* ACE_WIN32 */
74 * @class ImR_Activator_i
76 * @brief IMR Activator Interface.
78 * This class provides the interface for the various activities
79 * that can be done by the ImR_Activator.
82 class Activator_Export ImR_Activator_i
: public POA_ImplementationRepository::ActivatorExt
,
83 public ACE_Event_Handler
86 friend class Active_Pid_Setter
;
88 ImR_Activator_i (void);
90 void start_server (const char* name
,
93 const ImplementationRepository::EnvironmentList
& env
);
95 CORBA::Boolean
kill_server (const char* name
, CORBA::Long pid
, CORBA::Short signum
);
97 CORBA::Boolean
still_alive (CORBA::Long pid
);
101 /// Initialize the Server state - parsing arguments and waiting.
102 int init (Activator_Options
& opts
);
104 /// Cleans up any state created by init*.
107 int handle_timeout (const ACE_Time_Value
&, const void *tok
);
112 /// Shutdown the orb.
113 void shutdown (bool signaled
);
116 int init_with_orb (CORBA::ORB_ptr orb
, const Activator_Options
& opts
);
118 void register_with_imr(ImplementationRepository::Activator_ptr activator
);
120 // Handles the death of the child processes of the ImR_Activator.
121 // Informs the ImR_Locator too.
122 int handle_exit (ACE_Process
* process
);
123 int handle_exit_i (pid_t pid
);
125 bool still_running_i (const char *name
, pid_t
& pid
);
127 bool in_upcall (void);
130 typedef ACE_Unbounded_Set
<ACE_CString
> UniqueServerList
;
132 typedef ACE_Hash_Map_Manager_Ex
<pid_t
,
136 ACE_Null_Mutex
> ProcessMap
;
138 ACE_Process_Manager process_mgr_
;
140 PortableServer::POA_var root_poa_
;
141 PortableServer::POA_var imr_poa_
;
142 PortableServer::Current_var current_
;
144 ImplementationRepository::Locator_var locator_
;
146 /// We're given a token when registering with the locator, which
147 /// we must use when unregistering.
148 CORBA::Long registration_token_
;
156 unsigned int induce_delay_
;
160 ProcessMap process_map_
;
162 UniqueServerList running_server_list_
;
163 UniqueServerList dying_server_list_
;
165 /// The default environment buffer length
168 /// Maximum number of environment variables
172 pid_t active_check_pid_
;
173 #if defined (ACE_WIN32)
174 Watchdog process_watcher_
;
175 #endif /* ACE_WIN32 */
178 #if defined (ACE_WIN32)
179 class Active_Pid_Setter
182 Active_Pid_Setter(ImR_Activator_i
&owner
, pid_t pid
);
183 ~Active_Pid_Setter();
185 ImR_Activator_i
&owner_
;
187 #endif /* ACE_WIN32 */
189 #endif /* IMR_ACTIVATOR_I_H */