Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / ace / Service_Config.h
bloba3a785bad42e2e78c309fb294a43fed1d6b9803e
1 // -*- C++ -*-
3 //====================================================================
4 /**
5 * @file Service_Config.h
7 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
8 */
9 //====================================================================
11 #ifndef ACE_SERVICE_CONFIG_H
12 #define ACE_SERVICE_CONFIG_H
14 #include /**/ "ace/pre.h"
16 #include /**/ "ace/config-all.h"
17 #include "ace/Default_Constants.h"
18 #include "ace/Intrusive_Auto_Ptr.h"
19 #include "ace/Service_Gestalt.h"
20 #include "ace/Synch_Traits.h"
22 #if !defined (ACE_LACKS_PRAGMA_ONCE)
23 # pragma once
24 #endif /* ACE_LACKS_PRAGMA_ONCE */
26 #include "ace/OS_NS_signal.h"
28 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
30 // Forward decl.
31 class ACE_Service_Object;
32 class ACE_Service_Type;
33 class ACE_Service_Type_Impl;
34 class ACE_Service_Repository;
35 class ACE_Sig_Adapter;
36 class ACE_Allocator;
37 class ACE_Reactor;
38 class ACE_Thread_Manager;
39 class ACE_DLL;
41 #if (ACE_USES_CLASSIC_SVC_CONF == 1)
42 #define ACE_STATIC_SERVICE_DIRECTIVE(ident, parameters) \
43 ACE_TEXT ("static ") \
44 ACE_TEXT (ident) \
45 ACE_TEXT (" \"") \
46 ACE_TEXT (parameters) \
47 ACE_TEXT ("\"")
48 #define ACE_DYNAMIC_SERVICE_DIRECTIVE(ident, libpathname, objectclass, parameters) \
49 ACE_TEXT ("dynamic ") \
50 ACE_TEXT (ident) \
51 ACE_TEXT (" Service_Object * ") \
52 ACE_TEXT (libpathname) \
53 ACE_TEXT (":") \
54 ACE_TEXT (objectclass) \
55 ACE_TEXT ("() \"") \
56 ACE_TEXT (parameters) \
57 ACE_TEXT ("\"")
58 #if defined (ACE_VERSIONED_SO) && (ACE_VERSIONED_SO == 2)
59 #define ACE_DYNAMIC_VERSIONED_SERVICE_DIRECTIVE(ident, libpathname, version, objectclass, parameters) \
60 ACE_TEXT ("dynamic ") \
61 ACE_TEXT (ident) \
62 ACE_TEXT (" Service_Object * ") \
63 ACE_DLL_PREFIX \
64 ACE_TEXT (libpathname) \
65 ACE_TEXT ("-") \
66 ACE_TEXT (version) \
67 ACE_DLL_SUFFIX \
68 ACE_TEXT (":") \
69 ACE_TEXT (objectclass) \
70 ACE_TEXT ("() \"") \
71 ACE_TEXT (parameters) \
72 ACE_TEXT ("\"")
73 #else
74 #define ACE_DYNAMIC_VERSIONED_SERVICE_DIRECTIVE(ident, libpathname, version, objectclass, parameters) \
75 ACE_TEXT ("dynamic ") \
76 ACE_TEXT (ident) \
77 ACE_TEXT (" Service_Object * ") \
78 ACE_TEXT (libpathname) \
79 ACE_TEXT (":") \
80 ACE_TEXT (objectclass) \
81 ACE_TEXT ("() \"") \
82 ACE_TEXT (parameters) \
83 ACE_TEXT ("\"")
84 #endif /* ACE_VERSIONED_SO */
85 #define ACE_REMOVE_SERVICE_DIRECTIVE(ident) \
86 ACE_TEXT ("remove ") \
87 ACE_TEXT (ident)
88 class ACE_Svc_Conf_Param;
89 #else
90 #define ACE_STATIC_SERVICE_DIRECTIVE(ident, parameters) \
91 ACE_TEXT ("<ACE_Svc_Conf><static id=\"") \
92 ACE_TEXT (ident) \
93 ACE_TEXT ("\" params=\"") \
94 ACE_TEXT (parameters) \
95 ACE_TEXT ("\"/></ACE_Svc_Conf>")
96 #define ACE_DYNAMIC_SERVICE_DIRECTIVE(ident, libpathname, objectclass, parameters) \
97 ACE_TEXT ("<ACE_Svc_Conf><dynamic id=\"") \
98 ACE_TEXT (ident) \
99 ACE_TEXT ("\" type=\"Service_Object\">") \
100 ACE_TEXT ("<initializer path=\"") \
101 ACE_TEXT (libpathname) \
102 ACE_TEXT ("\" init=\"") \
103 ACE_TEXT (objectclass) \
104 ACE_TEXT ("\"") \
105 ACE_TEXT (" params=\"") \
106 ACE_TEXT (parameters) \
107 ACE_TEXT ("\"/></dynamic></ACE_Svc_Conf>")
108 #if defined (ACE_VERSIONED_SO) && (ACE_VERSIONED_SO == 2)
109 #define ACE_DYNAMIC_VERSIONED_SERVICE_DIRECTIVE(ident, libpathname, version, objectclass, parameters) \
110 ACE_TEXT ("<ACE_Svc_Conf><dynamic id=\"") \
111 ACE_TEXT (ident) \
112 ACE_TEXT ("\" type=\"Service_Object\">") \
113 ACE_TEXT ("<initializer path=\"") \
114 ACE_DLL_PREFIX \
115 ACE_TEXT (libpathname) \
116 ACE_TEXT ("-") \
117 ACE_TEXT (version) \
118 ACE_DLL_SUFFIX \
119 ACE_TEXT ("\" init=\"") \
120 ACE_TEXT (objectclass) \
121 ACE_TEXT ("\"") \
122 ACE_TEXT (" params=\"") \
123 ACE_TEXT (parameters) \
124 ACE_TEXT ("\"/></dynamic></ACE_Svc_Conf>")
125 #else
126 #define ACE_DYNAMIC_VERSIONED_SERVICE_DIRECTIVE(ident, libpathname, version, objectclass, parameters) \
127 ACE_TEXT ("<ACE_Svc_Conf><dynamic id=\"") \
128 ACE_TEXT (ident) \
129 ACE_TEXT ("\" type=\"Service_Object\">") \
130 ACE_TEXT ("<initializer path=\"") \
131 ACE_TEXT (libpathname) \
132 ACE_TEXT ("\" init=\"") \
133 ACE_TEXT (objectclass) \
134 ACE_TEXT ("\"") \
135 ACE_TEXT (" params=\"") \
136 ACE_TEXT (parameters) \
137 ACE_TEXT ("\"/></dynamic></ACE_Svc_Conf>")
138 #endif
139 #define ACE_REMOVE_SERVICE_DIRECTIVE(ident) \
140 ACE_TEXT ("<ACE_Svc_Conf><remove id=\"") \
141 ACE_TEXT (ident) \
142 ACE_TEXT ("\"></remove></ACE_Svc_Conf>")
143 class ACE_XML_Svc_Conf;
144 #endif /* ACE_USES_CLASSIC_SVC_CONF == 1 */
146 ACE_END_VERSIONED_NAMESPACE_DECL
148 extern "C"
150 typedef ACE_Service_Object *(*ACE_SERVICE_ALLOCATOR) (ACE_Service_Object_Exterminator *);
153 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
156 * @class ACE_Static_Svc_Descriptor
158 * @brief Holds the information necessary to describe a statically linked
159 * Svc.
161 class ACE_Static_Svc_Descriptor
163 public:
164 /// Name of the service.
165 const ACE_TCHAR *name_;
167 /// Type of service.
168 int type_;
170 /// Factory function that allocates the service.
171 ACE_SERVICE_ALLOCATOR alloc_;
173 /// Bitmask flags indicating how the framework should delete memory.
174 u_int flags_;
176 /// Flag indicating whether the service starts out active.
177 int active_;
179 /// Dump the state of an object.
180 void dump () const;
182 /// Declare the dynamic allocation hooks.
183 ACE_ALLOC_HOOK_DECLARE;
185 public:
186 /// Compare two service descriptors for equality.
187 bool operator== (ACE_Static_Svc_Descriptor &) const;
189 /// Compare two service descriptors for inequality.
190 bool operator!= (ACE_Static_Svc_Descriptor &) const;
195 * @class ACE_Threading_Helper
197 * @brief Encapsulates responsibility for allocating, destroying and
198 * manipulating the value, associated with a thread-specific
199 * key. Relates to the ability of the created thread to inherit the
200 * parent thread's gestalt. Designed to be used as an instance member
201 * of @c ACE_Service_Config.
203 * Partial specialization over ACE_SYNCH_MUTEX is used to implement
204 * specific behavior in both multi- and single-threaded builds.
206 template <typename LOCK>
207 class ACE_Threading_Helper
212 * Specialization for a multi threaded program
214 template<>
215 class ACE_Export ACE_Threading_Helper<ACE_Thread_Mutex>
217 public:
218 ACE_Threading_Helper ();
219 ~ACE_Threading_Helper ();
221 void set (void*);
222 void* get ();
224 private:
225 /// Key for the thread-specific data, which is a simple pointer to
226 /// the thread's (currently-) global configuration context.
227 ACE_thread_key_t key_;
231 * Specialization for a single threaded program
233 template<>
234 class ACE_Export ACE_Threading_Helper<ACE_Null_Mutex>
236 public:
237 ACE_Threading_Helper ();
238 ~ACE_Threading_Helper ();
240 void set (void*);
241 void* get ();
244 #define ACE_Component_Config ACE_Service_Config
247 * @class ACE_Service_Config
249 * @brief Supplies common server operations for dynamic and static
250 * configuration of service.
252 * The ACE_Service_Config uses the Monostate pattern. Therefore,
253 * you can only have one of these instantiated per-process. It
254 * represents the process-wide collection of services, which is
255 * typically shared among all other configurable entities. The only
256 * ACE_Service_Config instance is registered with and owned by the
257 * ACE_Object_Manager.
259 * By contrast, the ACE_Service_Gestalt represents the collection
260 * of services, pertaining to a configurable entity. Typically, a
261 * "configurable entity" is an instance, which owns an instance of
262 * ACE_Service_Gestalt in order to ensure full control over the
263 * services it needs.
265 * Another facet of ACE_Service_Config is that for a given thread,
266 * it provides access to its current, process-global
267 * ACE_Service_Gestalt instance through its current() method.
269 * @note The signal_handler_ static member is allocated by the
270 * ACE_Object_Manager. The ACE_Service_Config constructor
271 * uses signal_handler_. Therefore, if the program has any
272 * static ACE_Service_Config objects, there might be
273 * initialization order problems. They can be minimized, but
274 * not eliminated, by _not_ #defining
275 * ACE_HAS_NONSTATIC_OBJECT_MANAGER.
277 class ACE_Export ACE_Service_Config
279 /// The Instance, or the global (default) configuration context.
280 /// The monostate would forward the calls to that instance. The TSS
281 /// will point here
282 ACE_Intrusive_Auto_Ptr<ACE_Service_Gestalt> instance_;
284 /// A helper instance to manage thread-specific key creation.
285 /// Dependent on the syncronization mutex ACE uses, the corresponding
286 /// partial template instantiation will perform the right services
287 /// that have to do with managing thread-specific storage. Note that,
288 /// for single-threaded builds they would do (next to) nothing.
289 ACE_Threading_Helper<ACE_SYNCH_MUTEX> threadkey_;
291 public:
293 * Initialize the Service Repository. Note that initialising @a
294 * signum to a negative number will prevent a signal handler being
295 * registered when the repository is opened.
297 ACE_Service_Config (bool ignore_static_svcs = true,
298 size_t size = ACE_DEFAULT_SERVICE_REPOSITORY_SIZE,
299 int signum = SIGHUP);
302 * Performs an open without parsing command-line arguments. The
303 * @a logger_key indicates where to write the logging output, which
304 * is typically either a STREAM pipe or a socket address.
306 ACE_Service_Config (const ACE_TCHAR program_name[],
307 const ACE_TCHAR *logger_key = ACE_DEFAULT_LOGGER_KEY);
309 /// Perform user-specified close activities and remove dynamic
310 /// memory.
311 virtual ~ACE_Service_Config ();
313 private:
315 * Performs an open without parsing command-line arguments.
316 * Implements whats different in the opening sequence
317 * for this class, as opposed to the base class.
319 * The @a logger_key indicates where to write the logging output, which
320 * is typically either a STREAM pipe or a socket address. If
321 * @a ignore_default_svc_conf_file is non-0 then the "svc.conf" file
322 * will be ignored. If @a ignore_debug_flag is non-0 then the
323 * application is responsible for setting the
324 * @c ACE_Log_Msg::priority_mask() appropriately. Returns number of
325 * errors that occurred on failure and 0 otherwise.
327 virtual int open_i (const ACE_TCHAR program_name[],
328 const ACE_TCHAR *logger_key,
329 bool ignore_static_svcs,
330 bool ignore_default_svc_conf_file,
331 bool ignore_debug_flag);
334 * Implements whats different in the command line parameter processing
335 * for this class, as opposed to the base class.
337 virtual int parse_args_i (int argc, ACE_TCHAR *argv[]);
339 /// = Static interfaces
341 public:
343 * Returns the process-wide global singleton instance. It would
344 * have been created and will be managed by the Object Manager.
346 static ACE_Service_Config* singleton ();
349 * Mutator for the currently active configuration context instance
350 * (gestalt). Intended for use by helper classes like @see
351 * ACE_Service_Config_Guard. Stack-based instances can be used to
352 * temporarily change which gestalt is seen as global by static
353 * initializers (especially those in DLLs loaded at run-time).
355 static void current (ACE_Service_Gestalt*);
358 * Accessor for the "current" service gestalt
360 static ACE_Service_Gestalt* current ();
363 * This is what the static service initializators are hard-wired to
364 * use, so in order to avoid interface changes this method merely
365 * forwards to @c ACE_Service_Config::current. This enables us to
366 * enforce which Service Gestalt is used for services registering
367 * through static initializers. Especially important for DLL-based
368 * dynamic services, which can contain their own static services and
369 * static initializers.
371 * @deprecated Use current() instead.
373 static ACE_Service_Gestalt* instance ();
376 * Returns a process-wide global singleton instance in contrast with
377 * current (), which may return a different instance at different
378 * times, dependent on the context. Modifying this method's return
379 * value is strongly discouraged as it will circumvent the mechanism
380 * for dynamically loading services. If you must, use with extreme
381 * caution!
383 static ACE_Service_Gestalt* global ();
386 * Performs an open without parsing command-line arguments. The
387 * @a logger_key indicates where to write the logging output, which
388 * is typically either a STREAM pipe or a socket address. If
389 * @a ignore_static_svcs is true then static services are not loaded,
390 * otherwise, they are loaded. If @a ignore_default_svc_conf_file is
391 * non-0 then the <svc.conf> configuration file will be ignored.
392 * Returns zero upon success, -1 if the file is not found or cannot
393 * be opened (errno is set accordingly), otherwise returns the
394 * number of errors encountered loading the services in the
395 * specified svc.conf configuration file. If @a ignore_debug_flag is
396 * non-0 then the application is responsible for setting the
397 * @c ACE_Log_Msg::priority_mask appropriately.
399 static int open (const ACE_TCHAR program_name[],
400 const ACE_TCHAR *logger_key = ACE_DEFAULT_LOGGER_KEY,
401 bool ignore_static_svcs = true,
402 bool ignore_default_svc_conf_file = false,
403 bool ignore_debug_flag = false);
406 * This is the primary entry point into the ACE_Service_Config (the
407 * constructor just handles simple initializations). It parses
408 * arguments passed in from @a argc and @a argv parameters. The
409 * arguments that are valid in a call to this method include:
411 * - '-b' Option to indicate that we should be a daemon. Note that when
412 * this option is used, the process will be daemonized before the
413 * service configuration file(s) are read. During daemonization,
414 * (on POSIX systems) the current directory will be changed to "/"
415 * so the caller should either fully specify the file names, or
416 * execute a @c chroot() to the appropriate directory.
417 * @sa ACE::daemonize().
418 * - '-d' Turn on debugging mode
419 * - '-f' Specifies a configuration file name other than the default
420 * svc.conf. Can be specified multiple times to use multiple files.
421 * If any configuration file is provided with this option then
422 * the default svc.conf will be ignored.
423 * - '-k' Specifies the rendezvous point to use for the ACE distributed
424 * logger.
425 * - '-y' Explicitly enables the use of static services. This flag
426 * overrides the @a ignore_static_svcs parameter value.
427 * - '-n' Explicitly disables the use of static services. This flag
428 * overrides the @a ignore_static_svcs parameter value.
429 * - '-p' Specifies a pathname which is used to store the process id.
430 * - '-s' Specifies a signal number other than SIGHUP to trigger reprocessing
431 * of the configuration file(s). Ignored for platforms that do not
432 * have POSIX signals, such as Windows.
433 * - '-S' Specifies a service directive string. Enclose the string in quotes
434 * and escape any embedded quotes with a backslash. This option
435 * specifies service directives without the need for a configuration
436 * file. Can be specified multiple times.
438 * Note: Options '-f' and '-S' complement each other. Directives from files
439 * and from '-S' option are processed together in the following order. First,
440 * all files are processed in the order they are specified in @a argv
441 * parameter. Second, all directive strings are executed in the order the
442 * directives appear in @a argv parameter.
444 * @param argc The number of commandline arguments.
445 * @param argv The array with commandline arguments
446 * @param logger_key Indicates where to write the logging output,
447 * which is typically either a STREAM pipe or a
448 * socket address.
449 * @param ignore_static_svcs If true then static services are not loaded,
450 * otherwise, they are loaded.
451 * @param ignore_default_svc_conf_file If non-0 then the @c svc.conf
452 * configuration file will be ignored.
453 * @param ignore_debug_flag If true then the application is responsible
454 * for setting the @c ACE_Log_Msg::priority_mask
455 * appropriately.
457 * @retval -1 The configuration file is not found or cannot
458 * be opened (errno is set accordingly).
459 * @retval 0 Success.
460 * @retval >0 The number of errors encountered while processing
461 * the service configuration file(s).
463 static int open (int argc,
464 ACE_TCHAR *argv[],
465 const ACE_TCHAR *logger_key = ACE_DEFAULT_LOGGER_KEY,
466 bool ignore_static_svcs = true,
467 bool ignore_default_svc_conf_file = false,
468 bool ignore_debug_flag = false);
470 /// Tidy up and perform last rites when ACE_Service_Config is shut
471 /// down. This method calls close_svcs(). Returns 0.
472 static int close ();
474 /// Perform user-specified close hooks and possibly delete all of the
475 /// configured services in the <Service_Repository>.
476 static int fini_svcs ();
478 /// True if reconfiguration occurred.
479 static int reconfig_occurred ();
481 /// Indicate that reconfiguration occurred.
482 static void reconfig_occurred (int);
484 /// Perform the reconfiguration process.
485 static void reconfigure ();
487 // = The following methods are static in order to enforce Singleton
488 // semantics for the Reactor, Service_Repository, Thread_Manager,
489 // and Acceptor/Connector Strategy factory. Other portions of the
490 // system may need to access them at some point or another...
492 // = This is not strictly needed, anymore since the service configurator
493 // has been refactored to allow multiple service configuration
494 // instances (called gestalts). The interfaces, however were retained in for
495 // the sake of maintaining source-code compatibility.
498 // = Accessors and mutators for process-wide Singletons.
500 /// Returns a pointer to the list of statically linked services.
502 /// @deprecated - Same as instance(), but still useful in legacy code,
503 /// (notably, one that can not be easily modified) which uses the following
504 /// idiom for registering static services:
506 /// ACE_Service_Config::static_svcs ()->insert (...);
507 static ACE_Service_Gestalt* static_svcs ();
509 /// Insert a static service descriptor for processing on open_i(). The
510 /// corresponding ACE_STATIC_SVC_* macros were changed to use this method
511 /// instead of obtaining a ptr to a container. See the note on static_svcs().
512 /// Added to prevent exposing the internal storage representation of the
513 /// services repository and provide a better way of debugging service
514 /// loading and registration problems.
515 static int insert (ACE_Static_Svc_Descriptor *svc);
517 // = Utility methods.
518 /// Dynamically link the shared object file and retrieve a pointer to
519 /// the designated shared object in this file.
520 static int initialize (const ACE_Service_Type *,
521 const ACE_TCHAR *parameters);
523 /// Initialize and activate a statically @a svc_name service.
524 static int initialize (const ACE_TCHAR *svc_name,
525 const ACE_TCHAR *parameters);
527 /// Resume a @a svc_name that was previously suspended or has not yet
528 /// been resumed (e.g., a static service).
529 static int resume (const ACE_TCHAR svc_name[]);
532 * Suspend @a svc_name. Note that this will not unlink the service
533 * from the daemon if it was dynamically linked, it will mark it as
534 * being suspended in the Service Repository and call the <suspend>
535 * member function on the appropriate ACE_Service_Object. A
536 * service can be resumed later on by calling the <RESUME> member
537 * function...
539 static int suspend (const ACE_TCHAR svc_name[]);
541 /// Totally remove @a svc_name from the daemon by removing it
542 /// from the ACE_Reactor, and unlinking it if necessary.
543 static int remove (const ACE_TCHAR svc_name[]);
545 /// Dump the state of an object.
546 void dump () const;
548 /// Set the signal_handler for internal use by ACE_Object_Manager only.
549 static ACE_INLINE void signal_handler (ACE_Sig_Adapter *);
551 /// Declare the dynamic allocation hooks.
552 ACE_ALLOC_HOOK_DECLARE;
554 /// Process a file containing a list of service configuration
555 /// directives.
556 static int process_file (const ACE_TCHAR file[]);
558 /// Process one service configuration @a directive, which is passed as
559 /// a string. Returns the number of errors that occurred.
560 static int process_directive (const ACE_TCHAR directive[]);
563 * Process one static service definition. Load a new static service
564 * into the ACE_Service_Repository.
566 * @param ssd Service descriptor, see the document of
567 * ACE_Static_Svc_Descriptor for more details.
569 * @param force_replace If set the new service descriptor replaces
570 * any previous instance in the ACE_Service_Repository.
572 * @return Returns -1 if the service cannot be 'loaded'.
574 static int process_directive (const ACE_Static_Svc_Descriptor &ssd,
575 bool force_replace = false);
578 * Process (or re-process) service configuration requests that are
579 * provided in the svc.conf file(s). Returns the number of errors
580 * that occurred.
582 static int process_directives ();
584 /// Handles signals to trigger reconfigurations.
585 static void handle_signal (int sig, siginfo_t *, ucontext_t *);
588 * Handle the command-line options intended for the
589 * ACE_Service_Config. Note that @c argv[0] is assumed to be the
590 * program name.
591 * The arguments that are valid in a call to this method are
592 * - '-b' Option to indicate that we should be a daemon
593 * - '-d' Turn on debugging mode
594 * - '-f' Option to read in the list of svc.conf file names
595 * - '-k' Option to read a wide string where in the logger output can
596 * be written
597 * - '-y' Turn on the flag for a repository of statically
598 * linked services
599 * - '-n' Need not have a repository of statically linked services
600 * - '-S' Option to read in the list of services on the command-line
601 * Please observe the difference between options '-f' that looks
602 * for a list of files and here a list of services.
604 static int parse_args (int, ACE_TCHAR *argv[]);
606 #if (ACE_USES_CLASSIC_SVC_CONF == 0)
607 static ACE_Service_Type *create_service_type (const ACE_TCHAR *n,
608 ACE_Service_Type_Impl *o,
609 ACE_DLL &dll,
610 int active);
611 #endif /* ACE_USES_CLASSIC_SVC_CONF == 0 */
613 static ACE_Service_Type_Impl *
614 create_service_type_impl (const ACE_TCHAR *name,
615 int type,
616 void *symbol,
617 u_int flags,
618 ACE_Service_Object_Exterminator gobbler);
620 /// @deprecated
621 /// Process service configuration requests that were provided on the
622 /// command-line. Returns the number of errors that occurred.
623 static int process_commandline_directives ();
625 /// Become a daemon.
626 static int start_daemon ();
628 // @deprecated
629 // Add the default statically-linked services to the
630 // ACE_Service_Repository.
631 static int load_static_svcs ();
633 protected:
634 #if (ACE_USES_CLASSIC_SVC_CONF == 1)
635 /// @deprecated
636 /// This is the implementation function that process_directives()
637 /// and process_directive() both call. Returns the number of errors
638 /// that occurred.
639 static int process_directives_i (ACE_Svc_Conf_Param *param);
640 #endif /* ACE_USES_CLASSIC_SVC_CONF == 1 */
642 private:
643 /// Have we called ACE_Service_Config::open() yet?
644 bool is_opened_;
646 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
647 /// Synchronization variable for open, etc.
648 mutable ACE_SYNCH_MUTEX lock_;
649 #endif /* ACE_MT_SAFE */
651 /// True if reconfiguration occurred.
652 static sig_atomic_t reconfig_occurred_;
654 // = Set by command-line options.
655 /// Shall we become a daemon process?
656 static bool be_a_daemon_;
658 /// Pathname of file to write process id.
659 static ACE_TCHAR *pid_file_name_;
661 /// Number of the signal used to trigger reconfiguration.
662 static int signum_;
664 /// Handles the reconfiguration signals.
665 static ACE_Sig_Adapter *signal_handler_;
667 /// Pointer to the Singleton (ACE_Cleanup) Gestalt instance.
668 /// There is thread-specific global instance pointer, which is used to
669 /// temporarily change which Gestalt instance is used for static service
670 /// registrations.
672 /// A specific use case is a thread, which loads a _dynamic_ service from
673 /// a DLL. If the said DLL also contains additional _static_ services,
674 /// those *must* be registered with the same configuration repository as
675 /// the dynamic service. Otherwise, the DLL's static services would be
676 /// registered with the global Gestalt and may outlive the DLL that
677 /// contains their code and perhaps the memory in which they are in.
678 /// This is a problem because if the DLL gets unloaded (as it will, if
679 /// it was loaded in an instance of Gestalt), the DLL's memory will be
680 /// deallocated, but the global service repository will still "think"
681 /// it must finalize the (DLL's) static services - with disastrous
682 /// consequences, occurring in the post-main code (at_exit()).
684 /// This class needs the intimate access to be able to swap the
685 /// current TSS pointer for the global Gestalt.
686 friend class ACE_Service_Config_Guard;
688 /// The helper needs intimate access (when building with no threads)
689 friend class ACE_Threading_Helper <ACE_Thread_Mutex>;
690 friend class ACE_Threading_Helper <ACE_Null_Mutex>;
694 * @class ACE_Service_Config_Guard
696 * @brief A guard class, designed to be instantiated on the stack.
698 * Instantiating it with a specific configuration ensures any references to
699 * ACE_Service_Config::instance(), even when occurring in static constructors,
700 * will allways access the designated configuration instance.
701 * This comes very handy when a dynamic service also registers any static
702 * services of its own and their static factories.
704 class ACE_Export ACE_Service_Config_Guard
706 public:
707 ACE_Service_Config_Guard (ACE_Service_Gestalt* psg);
708 ~ACE_Service_Config_Guard ();
710 private:
711 ACE_Service_Config_Guard(const ACE_Service_Config_Guard&) = delete;
712 ACE_Service_Config_Guard& operator= (const ACE_Service_Config_Guard&) = delete;
714 private:
715 ACE_Intrusive_Auto_Ptr<ACE_Service_Gestalt> saved_;
718 ACE_END_VERSIONED_NAMESPACE_DECL
720 #if defined (__ACE_INLINE__)
721 #include "ace/Service_Config.inl"
722 #endif /* __ACE_INLINE__ */
724 #include /**/ "ace/post.h"
726 #endif /* ACE_SERVICE_CONFIG_H */