diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1998-09-04 18:59:32 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1998-09-04 18:59:32 +0000 |
commit | 3a8b3b069e34ce6c9d9050bffeb1799fc62ac24c (patch) | |
tree | 53cc9d9af2a9433ab358ed34bb4b842d590925af /ace | |
parent | 2265525390efc5f385616f3b22105c83788f4d82 (diff) | |
download | ATCD-3a8b3b069e34ce6c9d9050bffeb1799fc62ac24c.tar.gz |
*** empty log message ***
Diffstat (limited to 'ace')
-rw-r--r-- | ace/ACE.cpp | 3 | ||||
-rw-r--r-- | ace/ACE.h | 7 | ||||
-rw-r--r-- | ace/ACE.i | 12 | ||||
-rw-r--r-- | ace/Naming_Context.cpp | 8 | ||||
-rw-r--r-- | ace/Service_Config.cpp | 23 | ||||
-rw-r--r-- | ace/Service_Config.h | 14 | ||||
-rw-r--r-- | ace/Service_Config.i | 6 | ||||
-rw-r--r-- | ace/Service_Repository.cpp | 51 | ||||
-rw-r--r-- | ace/Service_Types.cpp | 49 |
9 files changed, 111 insertions, 62 deletions
diff --git a/ace/ACE.cpp b/ace/ACE.cpp index 8c596382c69..01671d6c77d 100644 --- a/ace/ACE.cpp +++ b/ace/ACE.cpp @@ -17,6 +17,9 @@ ACE_RCSID(ace, ACE, "$Id$") +// Keeps track of whether we're in some global debug mode. +char ACE::debug_ = 1; + // Hex characters. const char ACE::hex_chars_[] = "0123456789abcdef"; diff --git a/ace/ACE.h b/ace/ACE.h index a9a6ecd2ee6..7b9e3c09cc3 100644 --- a/ace/ACE.h +++ b/ace/ACE.h @@ -595,6 +595,10 @@ public: static u_char hex2byte (char c); // Convert a hex character to its byte representation. + // = Set/get the debug level. + static char debug (void); + static void debug (char d); + private: static int enter_recv_timedwait (ACE_HANDLE handle, const ACE_Time_Value *timeout, @@ -628,6 +632,9 @@ private: static const char hex_chars_[]; // Hex characters. + + static char debug_; + // Are we debugging ACE? }; #if !defined (ACE_LACKS_INLINE_FUNCTIONS) diff --git a/ace/ACE.i b/ace/ACE.i index 79a7682d9e3..492ac4a86c0 100644 --- a/ace/ACE.i +++ b/ace/ACE.i @@ -116,3 +116,15 @@ ACE::hex2byte (char c) else return (u_char) (10 + c - 'A'); } + +ACE_INLINE char +ACE::debug (void) +{ + return ACE::debug_; +} + +ACE_INLINE void +ACE::debug (char c) +{ + ACE::debug_ = c; +} diff --git a/ace/Naming_Context.cpp b/ace/Naming_Context.cpp index 50c8befc473..9eeae9e3e6a 100644 --- a/ace/Naming_Context.cpp +++ b/ace/Naming_Context.cpp @@ -345,7 +345,9 @@ ACE_Naming_Context::dump () int ACE_Naming_Context::init (int argc, char *argv[]) { - ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("ACE_Naming_Context::init\n"))); + if (ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ASYS_TEXT ("ACE_Naming_Context::init\n"))); this->name_options_->parse_args (argc, argv); return this->open (this->name_options_->context ()); } @@ -353,7 +355,9 @@ ACE_Naming_Context::init (int argc, char *argv[]) int ACE_Naming_Context::fini (void) { - ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("ACE_Naming_Context::fini\n"))); + if (ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ASYS_TEXT ("ACE_Naming_Context::fini\n"))); this->close_down (); diff --git a/ace/Service_Config.cpp b/ace/Service_Config.cpp index 3fc92fd2a54..270491b908a 100644 --- a/ace/Service_Config.cpp +++ b/ace/Service_Config.cpp @@ -48,7 +48,6 @@ ACE_Sig_Adapter *ACE_Service_Config::signal_handler_ = 0; sig_atomic_t ACE_Service_Config::reconfig_occurred_ = 0; // = Set by command-line options. -char ACE_Service_Config::debug_ = 1; char ACE_Service_Config::be_a_daemon_ = 0; char ACE_Service_Config::no_static_svcs_ = 1; @@ -207,7 +206,7 @@ ACE_Service_Config::parse_args (int argc, ASYS_TCHAR *argv[]) ACE_Service_Config::be_a_daemon_ = 1; break; case 'd': - ACE_Service_Config::debug_ = 0; + ACE::debug (0); break; case 'f': ACE_Service_Config::service_config_file_ = getopt.optarg; @@ -264,7 +263,7 @@ ACE_Service_Config::initialize (const ASYS_TCHAR svc_name[], ACE_ARGV args (parameters); ACE_Service_Type *srp = 0; - if (ACE_Service_Config::debug_) + if (ACE::debug ()) ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("opening static service %s\n"), svc_name)); @@ -299,7 +298,7 @@ ACE_Service_Config::initialize (const ACE_Service_Type *sr, ACE_TRACE ("ACE_Service_Config::initialize"); ACE_ARGV args (parameters); - if (ACE_Service_Config::debug_) + if (ACE::debug ()) ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("opening dynamic service %s\n"), sr->name ())); @@ -474,7 +473,7 @@ ACE_Service_Config::open (const ASYS_TCHAR program_name[], ACE_TRACE ("ACE_Service_Config::open"); // Clear the LM_DEBUG bit from log messages if appropriate - if (!ACE_Service_Config::debug_) + if (ACE::debug () == 0) ACE_Log_Msg::disable_debug_messages (); // Become a daemon before doing anything else. if (ACE_Service_Config::be_a_daemon_) @@ -499,7 +498,7 @@ ACE_Service_Config::open (const ASYS_TCHAR program_name[], retval = -1; else { - if (ACE_Service_Config::debug_) + if (ACE::debug ()) ACE_DEBUG ((LM_STARTUP, ASYS_TEXT ("starting up daemon %n\n"))); @@ -534,7 +533,7 @@ ACE_Service_Config::open (const ASYS_TCHAR program_name[], #endif /* ACE_LACKS_UNIX_SIGNALS */ } - if (!ACE_Service_Config::debug_) + if (ACE::debug () == 0) ACE_Log_Msg::enable_debug_messages (); return retval; @@ -566,7 +565,7 @@ ACE_Service_Config::handle_signal (int sig, siginfo_t *, ucontext_t *) sig, ACE_Service_Config::signum_)); - if (ACE_Service_Config::debug_) + if (ACE::debug ()) ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("signal %S occurred\n"), sig)); @@ -583,10 +582,10 @@ ACE_Service_Config::reconfigure (void) ACE_Service_Config::reconfig_occurred_ = 0; - if (ACE_Service_Config::debug_) + if (ACE::debug ()) { time_t t = ACE_OS::time (0); - if (ACE_Service_Config::debug_) + if (ACE::debug ()) ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("beginning reconfiguration at %s"), ACE_OS::ctime (&t))); @@ -676,12 +675,12 @@ ACE_Service_Config::fini_svcs (void) ACE_TRACE ("ACE_Service_Config::fini_svcs"); // Clear the LM_DEBUG bit from log messages if appropriate - if (!ACE_Service_Config::debug_) + if (ACE::debug () == 0) ACE_Log_Msg::disable_debug_messages (); int result = ACE_Service_Repository::instance ()->fini (); - if (!ACE_Service_Config::debug_) + if (ACE::debug () == 0) ACE_Log_Msg::enable_debug_messages (); return result; diff --git a/ace/Service_Config.h b/ace/Service_Config.h index d6d666b714e..56536a7c163 100644 --- a/ace/Service_Config.h +++ b/ace/Service_Config.h @@ -257,9 +257,6 @@ public: // Totally remove <svc_name> from the daemon by removing it // from the ACE_Reactor, and unlinking it if necessary. - static char debug (void); - // Returns the debug level. - #if defined (ACE_HAS_WINCE) // We must provide these function to bridge the <Svc_Conf> parser // with ACE. @@ -283,6 +280,9 @@ public: // Process one service configuration <directive>, which is passed as // a string. Returns the number of errors that occurred. + static void handle_signal (int sig, siginfo_t *, ucontext_t *); + // Handles signals to trigger reconfigurations. + protected: static int process_directives (void); // Process service configuration requests that are provided in the @@ -310,10 +310,6 @@ protected: // Add the default statically-linked services to the // <ACE_Service_Repository>. -public: - static void handle_signal (int sig, siginfo_t *, ucontext_t *); - // Handles signals to trigger reconfigurations. - private: static const ASYS_TCHAR *service_config_file_; // Name of service configuration file. @@ -331,9 +327,11 @@ private: // True if reconfiguration occurred. // = Set by command-line options. - static char debug_; static char be_a_daemon_; + // Shall we become a daemon process? + static char no_static_svcs_; + // Should we avoid loading the static services? static int signum_; // Number of the signal used to trigger reconfiguration. diff --git a/ace/Service_Config.i b/ace/Service_Config.i index 534b01fff80..309bce5f127 100644 --- a/ace/Service_Config.i +++ b/ace/Service_Config.i @@ -30,12 +30,6 @@ ACE_Service_Config::signal_handler (ACE_Sig_Adapter *signal_handler) signal_handler_ = signal_handler; } -ACE_INLINE char -ACE_Service_Config::debug (void) -{ - return ACE_Service_Config::debug_; -} - #if defined (ACE_HAS_WINCE) // We must provide these function to bridge Svc_Conf parser with ACE. diff --git a/ace/Service_Repository.cpp b/ace/Service_Repository.cpp index 317bbeaad3f..f92ba7cc640 100644 --- a/ace/Service_Repository.cpp +++ b/ace/Service_Repository.cpp @@ -17,7 +17,7 @@ ACE_ALLOC_HOOK_DEFINE(ACE_Service_Repository) ACE_Service_Repository *ACE_Service_Repository::svc_rep_ = 0; // Controls whether the Service_Repository is deleted when we shut -// down (we can only delete it safely if we created it!) +// down (we can only delete it safely if we created it)! int ACE_Service_Repository::delete_svc_rep_ = 0; void @@ -47,10 +47,13 @@ ACE_Service_Repository::instance (int size /* = ACE_Service_Repository::DEFAULT_ if (ACE_Service_Repository::svc_rep_ == 0) { - ACE_NEW_RETURN (ACE_Service_Repository::svc_rep_, ACE_Service_Repository (size), 0); + ACE_NEW_RETURN (ACE_Service_Repository::svc_rep_, + ACE_Service_Repository (size), + 0); ACE_Service_Repository::delete_svc_rep_ = 1; } } + return ACE_Service_Repository::svc_rep_; } @@ -92,14 +95,14 @@ ACE_Service_Repository::open (int size) { ACE_TRACE ("ACE_Service_Repository::open"); + ACE_Service_Type **temp; + + ACE_NEW_RETURN (temp, + ACE_Service_Type *[size], + -1); + + this->service_vector_ = (const ACE_Service_Type **) temp; this->total_size_ = size; - this->service_vector_ = - (const ACE_Service_Type **) new ACE_Service_Type *[size]; - if (this->service_vector_ == 0) - { - errno = ENOMEM; - return -1; - } return 0; } @@ -110,7 +113,9 @@ ACE_Service_Repository::ACE_Service_Repository (int size) ACE_TRACE ("ACE_Service_Repository::ACE_Service_Repository"); if (this->open (size) == -1) - ACE_ERROR ((LM_ERROR, ASYS_TEXT ("%p\n"), ASYS_TEXT ("ACE_Service_Repository"))); + ACE_ERROR ((LM_ERROR, + ASYS_TEXT ("%p\n"), + ASYS_TEXT ("ACE_Service_Repository"))); } // Finalize (call fini() and possibly delete) all the services. @@ -127,9 +132,11 @@ ACE_Service_Repository::fini (void) // they were added. for (int i = this->current_size_ - 1; i >= 0; i--) { - ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("finalizing %s\n"), - this->service_vector_[i]->name ())); - ((ACE_Service_Type *)this->service_vector_[i])->fini (); + if (ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ASYS_TEXT ("finalizing %s\n"), + this->service_vector_[i]->name ())); + ((ACE_Service_Type *) this->service_vector_[i])->fini (); } } return 0; @@ -150,9 +157,7 @@ ACE_Service_Repository::close (void) while (this->current_size_ > 0) { int i = --this->current_size_; - //ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("shutting down %s\n"), - // this->service_vector_[i]->name ())); - delete (ACE_Service_Type *)this->service_vector_[i]; + delete (ACE_Service_Type *) this->service_vector_[i]; } delete [] this->service_vector_; @@ -184,14 +189,16 @@ ACE_Service_Repository::find_i (const ASYS_TCHAR name[], int i; for (i = 0; i < this->current_size_; i++) - if (ACE_OS::strcmp (name, this->service_vector_[i]->name ()) == 0) + if (ACE_OS::strcmp (name, + this->service_vector_[i]->name ()) == 0) break; if (i < this->current_size_) { if (srp != 0) *srp = this->service_vector_[i]; - if (ignore_suspended && this->service_vector_[i]->active () == 0) + if (ignore_suspended + && this->service_vector_[i]->active () == 0) return -2; return i; } @@ -223,7 +230,7 @@ ACE_Service_Repository::insert (const ACE_Service_Type *sr) for (i = 0; i < this->current_size_; i++) if (ACE_OS::strcmp (sr->name (), - this->service_vector_[i]->name ()) == 0) + this->service_vector_[i]->name ()) == 0) break; if (i < this->current_size_) // Replacing an existing entry @@ -292,6 +299,7 @@ ACE_Service_Repository::remove (const ASYS_TCHAR name[]) { ACE_TRACE ("ACE_Service_Repository::remove"); ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + int i = this->find_i (name, 0, 0); if (i == -1) @@ -320,7 +328,8 @@ ACE_Service_Repository_Iterator::dump (void) const // perform destructive operations on elements during this iteration... ACE_Service_Repository_Iterator::ACE_Service_Repository_Iterator - (ACE_Service_Repository &sr, int ignr_suspended) + (ACE_Service_Repository &sr, + int ignr_suspended) : svc_rep_ (sr), next_ (-1), ignore_suspended_ (ignr_suspended) @@ -361,11 +370,13 @@ int ACE_Service_Repository_Iterator::advance (void) { ACE_TRACE ("ACE_Service_Repository_Iterator::advance"); + for (++this->next_; this->next_ < this->svc_rep_.current_size_ && this->ignore_suspended_ && this->svc_rep_.service_vector_[this->next_]->active () == 0; this->next_++) continue; + return this->next_ < this->svc_rep_.current_size_; } diff --git a/ace/Service_Types.cpp b/ace/Service_Types.cpp index e783c40966c..420ea9fce19 100644 --- a/ace/Service_Types.cpp +++ b/ace/Service_Types.cpp @@ -50,23 +50,27 @@ int ACE_Service_Type_Impl::fini (void) const { ACE_TRACE ("ACE_Service_Type_Impl::fini"); - ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("destroying %s, flags = %d\n"), - this->name_, this->flags_)); + if (ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ASYS_TEXT ("destroying %s, flags = %d\n"), + this->name_, + this->flags_)); delete [] (ASYS_TCHAR *) this->name_; ((ACE_Service_Type_Impl *) this)->name_ = 0; -#if 1 - if (ACE_BIT_ENABLED (this->flags_, ACE_Service_Type::DELETE_OBJ)) + if (ACE_BIT_ENABLED (this->flags_, + ACE_Service_Type::DELETE_OBJ)) { if (gobbler_ != 0) gobbler_ (this->object ()); else - operator delete ((void *) this->object ()); // cast to remove const-ness + // Cast to remove const-ness. + operator delete ((void *) this->object ()); } -#endif /* 0 */ - if (ACE_BIT_ENABLED (this->flags_, ACE_Service_Type::DELETE_THIS)) + if (ACE_BIT_ENABLED (this->flags_, + ACE_Service_Type::DELETE_THIS)) delete (ACE_Service_Type_Impl *) this; return 0; @@ -85,6 +89,7 @@ int ACE_Service_Object_Type::init (int argc, ASYS_TCHAR *argv[]) const { ACE_TRACE ("ACE_Service_Object_Type::init"); + void *obj = this->object (); ACE_Service_Object *so = (ACE_Service_Object *) obj; @@ -188,7 +193,10 @@ ACE_Module_Type::info (ASYS_TCHAR **str, size_t len) const ACE_TRACE ("ACE_Module_Type::info"); ASYS_TCHAR buf[BUFSIZ]; - ACE_OS::sprintf (buf, ASYS_TEXT ("%s\t %s"), this->name (), ASYS_TEXT ("# ACE_Module\n")); + ACE_OS::sprintf (buf, + ASYS_TEXT ("%s\t %s"), + this->name (), + ASYS_TEXT ("# ACE_Module\n")); if (*str == 0 && (*str = ACE_OS::strdup (buf)) == 0) return -1; @@ -230,7 +238,10 @@ int ACE_Stream_Type::suspend (void) const { ACE_TRACE ("ACE_Stream_Type::suspend"); - for (ACE_Module_Type *m = this->head_; m != 0; m = m->link ()) + + for (ACE_Module_Type *m = this->head_; + m != 0; + m = m->link ()) m->suspend (); return 0; @@ -240,7 +251,10 @@ int ACE_Stream_Type::resume (void) const { ACE_TRACE ("ACE_Stream_Type::resume"); - for (ACE_Module_Type *m = this->head_; m != 0; m = m->link ()) + + for (ACE_Module_Type *m = this->head_; + m != 0; + m = m->link ()) m->resume (); return 0; @@ -261,7 +275,10 @@ ACE_Stream_Type::info (ASYS_TCHAR **str, size_t len) const ACE_TRACE ("ACE_Stream_Type::info"); ASYS_TCHAR buf[BUFSIZ]; - ACE_OS::sprintf (buf, ASYS_TEXT ("%s\t %s"), this->name (), ASYS_TEXT ("# STREAM\n")); + ACE_OS::sprintf (buf, + ASYS_TEXT ("%s\t %s"), + this->name (), + ASYS_TEXT ("# STREAM\n")); if (*str == 0 && (*str = ACE_OS::strdup (buf)) == 0) return -1; @@ -282,7 +299,8 @@ ACE_Stream_Type::fini (void) const ACE_Module_Type *t = m->link (); // Final arg is an indication to *not* delete the Module. - str->remove (m->name (), MT_Module::M_DELETE_NONE); + str->remove (m->name (), + MT_Module::M_DELETE_NONE); // Finalize the Module (this may delete it, but we don't really // care since we don't access it again). @@ -300,6 +318,7 @@ int ACE_Stream_Type::remove (ACE_Module_Type *mod) { ACE_TRACE ("ACE_Stream_Type::remove"); + ACE_Module_Type *prev = 0; void *obj = this->object (); MT_Stream *str = (MT_Stream *) obj; @@ -318,7 +337,8 @@ ACE_Stream_Type::remove (ACE_Module_Type *mod) prev->link (link); // Final arg is an indication to *not* delete the Module. - if (str->remove (m->name (), MT_Module::M_DELETE_NONE) == -1) + if (str->remove (m->name (), + MT_Module::M_DELETE_NONE) == -1) result = -1; // This call may end up deleting m, which is ok since we @@ -375,7 +395,8 @@ ACE_Service_Object_Type::fini (void) const so->fini (); #if 0 - if (ACE_BIT_ENABLED (this->flags_, ACE_Service_Type::DELETE_OBJ)) + if (ACE_BIT_ENABLED (this->flags_, + ACE_Service_Type::DELETE_OBJ)) delete so; #endif /* 1 */ } |