diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1998-01-09 02:30:04 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1998-01-09 02:30:04 +0000 |
commit | 52d8f268f2ad8a7a175c8ad6c52b5bb0d1eaa8d0 (patch) | |
tree | 6e5d789e649399c88107bb1024ff9771813f0cbf | |
parent | ff08dd616e52ea320026464865d5cd28b1f9bfc7 (diff) | |
download | ATCD-52d8f268f2ad8a7a175c8ad6c52b5bb0d1eaa8d0.tar.gz |
*** empty log message ***
-rw-r--r-- | ChangeLog-98a | 18 | ||||
-rw-r--r-- | ace/Log_Msg.cpp | 53 | ||||
-rw-r--r-- | ace/Log_Msg.h | 53 | ||||
-rw-r--r-- | examples/Service_Configurator/IPC-tests/server/server_test.cpp | 17 |
4 files changed, 97 insertions, 44 deletions
diff --git a/ChangeLog-98a b/ChangeLog-98a index 4431d408d0f..8775536b087 100644 --- a/ChangeLog-98a +++ b/ChangeLog-98a @@ -1,4 +1,20 @@ -Thu Jan 8 18:39:22 1998 Douglas C. Schmidt <schmidt@flamenco.cs.wustl.edu> +Thu Jan 8 19:50:43 1998 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> + + * ace/Log_Msg: Added changes to allow the logging of custom built + log records. The main reason for these changes is to allow code + to handle the logging of out of memory conditions without + allocating any additional memory. Thanks to Patrick + J. McNerthney <pat@thememedia.com> for this feature. + + * ace/Log_Msg: Added a new method called log_priority_enabled(), + which returns true if the priority is enabled (gee, is *that* + what it does? ;-)). Thanks to Patrick J. McNerthney + <pat@thememedia.com> for this feature. + + * examples/Service_Configurator/IPC-tests/server/server_test.cpp + (main): Revised the driver program so that it doesn't create an + explicit ACE_Service_Config object. Thanks to John Mulhern + <9107@MN3.LAWSON.lawson.com> for reporting this. * apps/Gateway/{Gateway,Peer}/Options.cpp: Oops, ACE_BUILD_DLL should be ACE_BUILD_SVC_DLL, yikes! Thanks to Jeff Hellzen diff --git a/ace/Log_Msg.cpp b/ace/Log_Msg.cpp index 28c30aa495b..f6da555cf15 100644 --- a/ace/Log_Msg.cpp +++ b/ace/Log_Msg.cpp @@ -203,11 +203,11 @@ ACE_Log_Msg::instance (void) if (tss_log_msg == 0) { // Allocate memory off the heap and store it in a pointer in - // thread-specific storage (on the stack...). - // Stop heap checking, the memory will always be freed by the - // thread rundown because of the TSS callback set up when the key - // was created. This prevents from getting these blocks - // reported as memory leaks. + // thread-specific storage (on the stack...). Stop heap + // checking, the memory will always be freed by the thread + // rundown because of the TSS callback set up when the key was + // created. This prevents from getting these blocks reported as + // memory leaks. { ACE_NO_HEAP_CHECK; @@ -353,6 +353,12 @@ ACE_Log_Msg::priority_mask (void) } int +ACE_Log_Msg::log_priority_enabled (ACE_Log_Priority log_priority) +{ + return ACE_BIT_ENABLED (this->priority_mask_, log_priority); +} + +int ACE_Log_Msg::release (void) { ACE_TRACE ("ACE_Log_Msg::release"); @@ -564,7 +570,7 @@ ACE_Log_Msg::log (const char *format_str, // Only print the message if <priority_mask_> hasn't been reset to // exclude this logging priority. - if (ACE_BIT_DISABLED (this->priority_mask_, log_priority)) + if (this->log_priority_enabled (log_priority) == 0) return 0; ACE_Log_Record log_record (log_priority, @@ -573,7 +579,6 @@ ACE_Log_Msg::log (const char *format_str, char *bp = (char *) this->msg (); int abort_prog = 0; int exit_value = 0; - int result = 0; char *format; ACE_ALLOCATOR_RETURN (format, ACE_OS::strdup (format_str), -1); char *save_p = format; // Remember pointer for ACE_OS::free() @@ -868,8 +873,29 @@ ACE_Log_Msg::log (const char *format_str, ACE_OS::free (ACE_MALLOC_T (save_p)); + ssize_t result = this->log (log_record, abort_prog == 0); + + if (abort_prog) + { + // *Always* print a message to stderr if we're aborting. We + // don't use verbose, however, to avoid recursive aborts if + // something is hosed. + log_record.print (ACE_Log_Msg::local_host_, 0); + ACE_OS::exit (exit_value); + } + + return result; +} + +ssize_t +ACE_Log_Msg::log (ACE_Log_Record &log_record, + int suppress_stderr) +{ + ssize_t result = 0; + // Only print the message if "SILENT" mode is disabled. - if (ACE_BIT_DISABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::SILENT)) + if (ACE_BIT_DISABLED (ACE_Log_Msg::flags_, + ACE_Log_Msg::SILENT)) { // Copy the message from thread-specific storage into the // transfer buffer (this can be optimized away by changing other @@ -886,7 +912,7 @@ ACE_Log_Msg::log (const char *format_str, ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, *ACE_Log_Msg_Manager::get_lock (), -1)); if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::STDERR) - && abort_prog == 0) // We'll get this further down. + && !suppress_stderr) // This is taken care of by our caller. log_record.print (ACE_Log_Msg::local_host_, ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::VERBOSE), stderr); @@ -922,15 +948,6 @@ ACE_Log_Msg::log (const char *format_str, this->start_tracing (); } - if (abort_prog) - { - // *Always* print a message to stderr if we're aborting. We - // don't use verbose, however, to avoid recursive aborts if - // something is hosed. - log_record.print (ACE_Log_Msg::local_host_, 0); - ACE_OS::exit (exit_value); - } - return result; } diff --git a/ace/Log_Msg.h b/ace/Log_Msg.h index 4e87df1cb14..5baf64d6823 100644 --- a/ace/Log_Msg.h +++ b/ace/Log_Msg.h @@ -162,33 +162,38 @@ public: u_long flags (void); // Return the bits in the logger's options flags. - // = Operations that allow applications to acquire and release the - // synchronization lock used internally by the ACE_Log_Msg - // implementation. This allows applications to hold the lock - // atomically over a number of calls to ACE_Log_Msg. + // = Allow apps to acquire and release internal synchronization lock. + + // This lock is used internally by the <ACE_Log_Msg> implementation. + // By exporting the lock, applications can hold the lock atomically + // over a number of calls to <ACE_Log_Msg>. int acquire (void); // Acquire the internal lock. int release (void); // Release the internal lock. void sync (const char *program_name); - // Call after doing a fork() to resynchronize the PID and - // PROGRAM_NAME variables. + // Call after doing a <fork> to resynchronize the process id and + // <program_name> variables. // = Set/get methods. Note that these are non-static and thus will // be thread-specific. void op_status (int status); - // Set the result of the operation status (by convention, -1 means error). + // Set the result of the operation status (by convention, -1 means + // error). int op_status (void); - // Get the result of the operation status (by convention, -1 means error). + // Get the result of the operation status (by convention, -1 means + // error). void errnum (int); - // Set the value of the errnum (by convention this corresponds to errno). + // Set the value of the errnum (by convention this corresponds to + // errno). int errnum (void); - // Get the value of the errnum (by convention this corresponds to errno). + // Get the value of the errnum (by convention this corresponds to + // errno). void linenum (int); // Set the line number where an error occurred. @@ -240,8 +245,8 @@ public: void thr_desc (ACE_Thread_Descriptor *td, ACE_Thread_Manager *thr_mgr = 0); // Set the TSS thread descriptor. This method will call - // thr_mgr->acquire_release to block execution until this - // call return. + // thr_mgr->acquire_release to block execution until this call + // return. // = Stop/start/query tracing status on a per-thread basis... void stop_tracing (void); @@ -254,9 +259,12 @@ public: u_long priority_mask (u_long); // Set the <ACE_Log_Priority> mask, returns original mask. + int log_priority_enabled (ACE_Log_Priority log_priority); + // Return true if the requested priority is enabled. + pid_t getpid (void) const; - // Optimize reading of the pid (avoids a system call if the - // value is cached...). + // Optimize reading of the pid (avoids a system call if the value is + // cached...). // = Set/get the name of the local host. const char *local_host (void) const; @@ -297,11 +305,18 @@ public: // 'X', 'x': print as a hex number // '%': print out a single percent sign, '%' - ssize_t log (const char *format, ACE_Log_Priority priority, va_list argp); + ssize_t log (const char *format, + ACE_Log_Priority priority, + va_list argp); // An alternative logging mechanism that makes it possible to // integrate variable argument lists from other logging mechanisms // into the ACE mechanism. + ssize_t log (ACE_Log_Record &log_record, + int suppress_stderr = 0); + // Log a custom built log record to the currently enabled logging + // sinks. + int log_hexdump (ACE_Log_Priority log_priority, const char *buffer, int size, @@ -359,8 +374,9 @@ private: // currently enabled. Default is for all logging priorities to be // enabled. - // = The following fields are *not* kept in thread-specific storage - // since we only want one instance for the entire process! + // = The following fields are *not* kept in thread-specific storage. + + // We only want one instance for the entire process! static const char *program_name_; // Records the program name. @@ -378,7 +394,8 @@ private: // Offset of msg_[]. static int instance_count_; - // Number of existing Log_Msg instances; when 0, delete program/host names + // Number of existing Log_Msg instances; when 0, delete program/host + // names static void close (void); // For cleanup, at program termination. diff --git a/examples/Service_Configurator/IPC-tests/server/server_test.cpp b/examples/Service_Configurator/IPC-tests/server/server_test.cpp index 528aaac3172..04440f729a7 100644 --- a/examples/Service_Configurator/IPC-tests/server/server_test.cpp +++ b/examples/Service_Configurator/IPC-tests/server/server_test.cpp @@ -7,22 +7,25 @@ int main (int argc, char *argv[]) { - ACE_Service_Config server_test; - - if (server_test.open (argc, argv) == -1) + if (ACE_Service_Test::open (argc, argv) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "server_test.open"), -1); // Create an adapter to end the event loop. ACE_Sig_Adapter sa ((ACE_Sig_Handler_Ex) ACE_Reactor::end_event_loop); - // Register a signal handler. - ACE_Reactor::instance ()->register_handler (SIGINT, &sa); + ACE_Sig_Set sig_set; + sig_set.sig_add (SIGINT); + sig_set.sig_add (SIGQUIT); + + // Register ourselves to receive signals so we can shut down + // gracefully. + if (ACE_Reactor::instance ()->register_handler (sig_set, &sa) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n"), -1); // Run forever, performing the configured services until we are shut // down by a SIGINT/SIGQUIT signal. - while (ACE_Reactor::event_loop_done() == 0) - ACE_Reactor::run_event_loop (); + ACE_Reactor::run_event_loop (); return 0; } |