diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1999-09-02 19:22:35 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1999-09-02 19:22:35 +0000 |
commit | d8e92a620a47602056e69777d6273675b96f6d29 (patch) | |
tree | de42c1552983f05f4c3bb89d7840ad64653e543b | |
parent | 1c8386a2a516deb17e1ca8865d9665fd2f618806 (diff) | |
download | ATCD-d8e92a620a47602056e69777d6273675b96f6d29.tar.gz |
ChangeLogTag:Thu Sep 2 12:21:41 1999 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu>
-rw-r--r-- | TAO/docs/Options.html | 32 | ||||
-rw-r--r-- | THANKS | 3 | ||||
-rw-r--r-- | ace/Log_Msg.cpp | 120 | ||||
-rw-r--r-- | ace/Log_Msg.h | 7 | ||||
-rw-r--r-- | ace/OS.cpp | 22 | ||||
-rw-r--r-- | ace/OS.h | 4 | ||||
-rw-r--r-- | ace/config-win32-common.h | 3 | ||||
-rw-r--r-- | examples/Log_Msg/test_callback.cpp | 101 | ||||
-rw-r--r-- | tests/Cached_Accept_Conn_Test.cpp | 3 |
9 files changed, 190 insertions, 105 deletions
diff --git a/TAO/docs/Options.html b/TAO/docs/Options.html index 8d212682837..e7817f865af 100644 --- a/TAO/docs/Options.html +++ b/TAO/docs/Options.html @@ -16,22 +16,22 @@ bgcolor="#ffffff"> <H3>Overview</H3> <blockquote> -<P>Certain components in TAO such as the ORB Core or Object Adapter -can be tuned by users by providing value for options or environment -variables to them. These options are commonly specified as (1) -environment variables or (2) strings passed on the command-line. They -are generally passed to component initialization methods for -consumption.</P> - -<p>Both command-line options and environment variables are used to -control the global ORB features like the IOR format or ORB's -bootstraping methods. Options in <code>svc.conf</code> file on the -other hand provides a mechanism to fine-tune the internal components -in TAO and they are specific to individual components. -<code>svc.conf</code> files are not required to run TAO programs. -However, if you know the behavior of your programs, you can tune-up -your programs and use various optimization provided by TAO thru the -use of svc.conf files.</p> +<p>TAO can be configured in several ways. Certain components in TAO, +such as the ORB Core or Object Adapter, can be tuned by users by +providing value for options or environment variables to them. These +options are commonly specified as (1) environment variables or (2) +strings passed on the command-line. Command-line options and +environment variables to control global ORB features, such as the IOR +format or ORB's bootstraping methods. They are generally passed to +component initialization methods for consumption. <P> + +In addition, options in <code>svc.conf</code> file provide a mechanism +to fine-tune internal components in TAO that are specific to +particular configurations. If your program use-cases have particular +characteristics, you can use the <code>svc.conf</code> file to +customize your programs and use various optimization provided by TAO . +However, a <code>svc.conf</code> file is not required to run TAO +programs. </p> <P><EM>Programmer's Note:</EM> the internal structure for options is the traditional <CODE>argc</CODE>/<CODE>argv</CODE> vector of strings @@ -747,6 +747,9 @@ Herbert <herbert@shym.com> Clarence Bishop <clarence.bishop@na.marconicomms.com> Giga Giguashvili <gregoryg@ParadigmGeo.com> Philipp Slusallek <slusallek@graphics.stanford.edu> +Matthew Davis <matthew.davis@solers.com> +Janusz Stopa <jstopa@bear.com> +Rusty Conover <rconover@zootweb.com> I would particularly like to thank Paul Stephenson, who worked with me at Ericsson. Paul devised the recursive Makefile scheme that diff --git a/ace/Log_Msg.cpp b/ace/Log_Msg.cpp index 682b23b15fc..5bc0ca1d4d5 100644 --- a/ace/Log_Msg.cpp +++ b/ace/Log_Msg.cpp @@ -593,28 +593,40 @@ ACE_Log_Msg::open (const ASYS_TCHAR *prog_name, // Remember, ACE_Log_Msg::STDERR bit is on by default... if (status != -1 - && ACE_BIT_ENABLED (flags, ACE_Log_Msg::STDERR) == 0) - ACE_CLR_BITS (ACE_Log_Msg::flags_, ACE_Log_Msg::STDERR); + && ACE_BIT_ENABLED (flags, + ACE_Log_Msg::STDERR) == 0) + ACE_CLR_BITS (ACE_Log_Msg::flags_, + ACE_Log_Msg::STDERR); // VERBOSE takes precedence over VERBOSE_LITE... - if (ACE_BIT_ENABLED (flags, ACE_Log_Msg::VERBOSE_LITE)) - ACE_SET_BITS (ACE_Log_Msg::flags_, ACE_Log_Msg::VERBOSE_LITE); - else if (ACE_BIT_ENABLED (flags, ACE_Log_Msg::VERBOSE)) - ACE_SET_BITS (ACE_Log_Msg::flags_, ACE_Log_Msg::VERBOSE); - - if (ACE_BIT_ENABLED (flags, ACE_Log_Msg::OSTREAM)) + if (ACE_BIT_ENABLED (flags, + ACE_Log_Msg::VERBOSE_LITE)) + ACE_SET_BITS (ACE_Log_Msg::flags_, + ACE_Log_Msg::VERBOSE_LITE); + else if (ACE_BIT_ENABLED (flags, + ACE_Log_Msg::VERBOSE)) + ACE_SET_BITS (ACE_Log_Msg::flags_, + ACE_Log_Msg::VERBOSE); + + if (ACE_BIT_ENABLED (flags, + ACE_Log_Msg::OSTREAM)) { - ACE_SET_BITS (ACE_Log_Msg::flags_, ACE_Log_Msg::OSTREAM); + ACE_SET_BITS (ACE_Log_Msg::flags_, + ACE_Log_Msg::OSTREAM); // Only set this to cerr if it hasn't already been set. if (this->msg_ostream () == 0) this->msg_ostream (ACE_DEFAULT_LOG_STREAM); } - if (ACE_BIT_ENABLED (flags, ACE_Log_Msg::MSG_CALLBACK)) - ACE_SET_BITS (ACE_Log_Msg::flags_, ACE_Log_Msg::MSG_CALLBACK); + if (ACE_BIT_ENABLED (flags, + ACE_Log_Msg::MSG_CALLBACK)) + ACE_SET_BITS (ACE_Log_Msg::flags_, + ACE_Log_Msg::MSG_CALLBACK); - if (ACE_BIT_ENABLED (flags, ACE_Log_Msg::SILENT)) - ACE_SET_BITS (ACE_Log_Msg::flags_, ACE_Log_Msg::SILENT); + if (ACE_BIT_ENABLED (flags, + ACE_Log_Msg::SILENT)) + ACE_SET_BITS (ACE_Log_Msg::flags_, + ACE_Log_Msg::SILENT); return status; } @@ -656,8 +668,9 @@ ACE_Log_Msg::log (ACE_Log_Priority log_priority, va_start (argp, format_str); - int result = this->log (format_str, log_priority, argp); - + int result = this->log (format_str, + log_priority, + argp); va_end (argp); return result; @@ -1082,7 +1095,8 @@ ACE_Log_Msg::log (const ASYS_TCHAR *format_str, log_record.msg_data (this->msg ()); // Write the <log_record> to the appropriate location. - ssize_t result = this->log (log_record, abort_prog); + ssize_t result = this->log (log_record, + abort_prog); if (abort_prog) { @@ -1176,7 +1190,8 @@ ACE_Log_Msg::log (ACE_Log_Record &log_record, // Make sure that the lock is held during all this. ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, - *ACE_Log_Msg_Manager::get_lock (), -1)); + *ACE_Log_Msg_Manager::get_lock (), + -1)); if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::STDERR) @@ -1186,24 +1201,28 @@ ACE_Log_Msg::log (ACE_Log_Record &log_record, #if defined (ACE_HAS_WINCE) ); #else - , stderr); + , stderr); #endif /* ACE_HAS_WINCE */ if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::LOGGER)) { #if defined (ACE_HAS_STREAM_PIPES) - ACE_Str_Buf log_msg (ACE_static_cast (void *, &log_record), - ACE_static_cast (int, log_record.length ())); + ACE_Str_Buf log_msg (ACE_static_cast (void *, + &log_record), + ACE_static_cast (int, + log_record.length ())); // Try to use the <putpmsg> API if possible in order to // ensure correct message queueing according to priority. result = - ACE_Log_Msg_Manager::message_queue_->send ( - ACE_reinterpret_cast (const ACE_Str_Buf *, 0), - &log_msg, - ACE_static_cast (int, log_record.priority ()), - MSG_BAND); + ACE_Log_Msg_Manager::message_queue_->send + (ACE_reinterpret_cast (const ACE_Str_Buf *, + 0), + &log_msg, + ACE_static_cast (int, + log_record.priority ()), + MSG_BAND); #else // We're running over sockets, so we'll need to indicate the // number of bytes to send. @@ -1215,7 +1234,7 @@ ACE_Log_Msg::log (ACE_Log_Record &log_record, // Format the message and print it to stderr and/or ship it off // to the log_client daemon, and/or print it to the ostream. // This must come last, after the other two print operations - // (see the ACE_Log_Record::print method for details). + // (see the <ACE_Log_Record::print> method for details). if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::OSTREAM) @@ -1223,19 +1242,28 @@ ACE_Log_Msg::log (ACE_Log_Record &log_record, log_record.print (ACE_Log_Msg::local_host_, ACE_Log_Msg::flags_, #if defined (ACE_LACKS_IOSTREAM_TOTALLY) - ACE_static_cast (FILE *, this->msg_ostream ())); + ACE_static_cast (FILE *, + this->msg_ostream ()) #else /* ! ACE_LACKS_IOSTREAM_TOTALLY */ - *this->msg_ostream ()); + *this->msg_ostream () #endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */ - + ); if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::MSG_CALLBACK) && this->msg_callback () != 0) - this->msg_callback ()->log (log_record); - + { + // Use a "reverse lock" to avoid holding the lock during the + // callback so we don't have deadlock if the callback uses + // the logger. + ACE_MT (ACE_Reverse_Lock<ACE_Recursive_Thread_Mutex> reverse_lock + (*ACE_Log_Msg_Manager::get_lock ())); + ACE_MT (ACE_GUARD_RETURN (ACE_Reverse_Lock<ACE_Recursive_Thread_Mutex>, + ace_mon_1, reverse_lock, -1)); + this->msg_callback ()->log (log_record); + } if (tracing) this->start_tracing (); - } + } return result; } @@ -1256,22 +1284,32 @@ ACE_Log_Msg::log_hexdump (ACE_Log_Priority log_priority, buf[0] = 0; // in case size = 0 - int len = ACE::format_hexdump (buffer, size, buf, + int len = ACE::format_hexdump (buffer, + size, + buf, sizeof (buf) / sizeof (ASYS_TCHAR)); int sz = 0; if (text) - sz = ACE_OS::sprintf (msg_buf, ASYS_TEXT ("%s - "), text); + sz = ACE_OS::sprintf (msg_buf, + ASYS_TEXT ("%s - "), + text); - sz += ACE_OS::sprintf (msg_buf + sz, ASYS_TEXT ("HEXDUMP %d bytes"), size); + sz += ACE_OS::sprintf (msg_buf + sz, + ASYS_TEXT ("HEXDUMP %d bytes"), + size); if (len < size) - ACE_OS::sprintf (msg_buf + sz, ASYS_TEXT (" (showing first %d bytes)"), + ACE_OS::sprintf (msg_buf + sz, + ASYS_TEXT (" (showing first %d bytes)"), len); // Now print out the formatted buffer. - this->log (log_priority, ASYS_TEXT ("%s\n%s"), msg_buf, buf); + this->log (log_priority, + ASYS_TEXT ("%s\n%s"), + msg_buf, + buf); return 0; } @@ -1520,10 +1558,12 @@ ACE_Log_Msg::msg_callback (void) const return this->msg_callback_; } -void +ACE_Log_Msg_Callback * ACE_Log_Msg::msg_callback (ACE_Log_Msg_Callback *c) { + ACE_Log_Msg_Callback *old = this->msg_callback_; this->msg_callback_ = c; + return old; } ACE_OSTREAM_TYPE * @@ -1574,9 +1614,13 @@ ACE_Log_Msg_Callback::~ACE_Log_Msg_Callback (void) #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) # if !defined (ACE_MT_SAFE) || (ACE_MT_SAFE == 0) template class ACE_Cleanup_Adapter<ACE_Log_Msg>; +#else +template class ACE_Reverse_Lock<ACE_Recursive_Thread_Mutex>; # endif /* ! ACE_MT_SAFE */ #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) # if !defined (ACE_MT_SAFE) || (ACE_MT_SAFE == 0) # pragma instantiate ACE_Cleanup_Adapter<ACE_Log_Msg> +#else +#pragma instantiate ACE_Reverse_Lock<ACE_Recursive_Thread_Mutex> # endif /* ! ACE_MT_SAFE */ #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/ace/Log_Msg.h b/ace/Log_Msg.h index 8d4c85c6c75..74ff91599ec 100644 --- a/ace/Log_Msg.h +++ b/ace/Log_Msg.h @@ -280,11 +280,12 @@ public: void msg_ostream (ACE_OSTREAM_TYPE *); ACE_OSTREAM_TYPE *msg_ostream (void) const; - // Set/Get the ostream that is used to print error messages. + // Get the ostream that is used to print error messages. - void msg_callback (ACE_Log_Msg_Callback *c); + ACE_Log_Msg_Callback *msg_callback (ACE_Log_Msg_Callback *c); ACE_Log_Msg_Callback *msg_callback (void) const; - // Set/Get the callback object. + // Set a new callback object and return the existing callback to + // allow "chaining". // = Nesting depth increment and decrement. int inc (void); diff --git a/ace/OS.cpp b/ace/OS.cpp index b5ef202511b..225a4f696c0 100644 --- a/ace/OS.cpp +++ b/ace/OS.cpp @@ -6957,9 +6957,9 @@ ACE_OS::strptime (char *buf, struct tm *tm) { #if defined (ACE_LACKS_NATIVE_STRPTIME) - int bi = 0, fi = 0, percent = 0; - int wday = 0, yday = 0; - struct tm tmp; + int bi = 0; + int fi = 0; + int percent = 0; if (!buf || !format) return 0; @@ -6971,7 +6971,7 @@ ACE_OS::strptime (char *buf, percent = 0; switch (format[fi]) { - case '%': /* an escaped % */ + case '%': // an escaped % if (buf[bi] == '%') { fi++; bi++; @@ -7059,7 +7059,6 @@ ACE_OS::strptime (char *buf, return buf + bi; tm->tm_yday--; - yday = 1; break; case 'm': /* an escaped % */ @@ -7127,7 +7126,6 @@ ACE_OS::strptime (char *buf, if (!ACE_OS::strptime_getnum (buf + bi, &tm->tm_wday, &bi, &fi, 0, 6)) return buf + bi; - wday = 1; break; /* not supported yet: date, based on locale @@ -7180,18 +7178,6 @@ ACE_OS::strptime (char *buf, } /* if (percent) */ } /* while (format[fi] */ - if (!wday || !yday) - { - ACE_OS::memcpy (&tmp, tm, sizeof (struct tm)); - if (mktime (&tmp) != (time_t) (-1)) - { - if (!wday) - tm->tm_wday = tmp.tm_wday; - if (!yday) - tm->tm_yday = tmp.tm_yday; - } - } - return buf + bi; #else /* ! ACE_LACKS_NATIVE_STRPTIME */ return ::strptime (buf, @@ -1747,7 +1747,9 @@ static ACE_Static_Svc_##X ace_static_svc_##X; // More generic dynamic/static service macros. # define ACE_FACTORY_DECLARE(CLS,X) extern "C" CLS##_Export ACE_Service_Object *_make_##X (ACE_Service_Object_Exterminator *); # define ACE_FACTORY_DEFINE(CLS,X) \ -extern "C" void _gobble_##X (void *p) { X *_p = (X *) p; delete _p; } \ +extern "C" void _gobble_##X (void *p) { \ + X *_p = ACE_static_cast (X *, ACE_reinterpret_cast (ACE_Service_Object *, p)); \ + delete _p; } \ extern "C" ACE_Service_Object *_make_##X (ACE_Service_Object_Exterminator *gobbler) \ { ACE_TRACE (#X); \ if (gobbler != 0) *gobbler = (ACE_Service_Object_Exterminator) _gobble_##X; return new X; } diff --git a/ace/config-win32-common.h b/ace/config-win32-common.h index ab4dc4dd8dd..bae9a62df5c 100644 --- a/ace/config-win32-common.h +++ b/ace/config-win32-common.h @@ -99,7 +99,8 @@ typedef unsigned __int64 ACE_UINT64; // Platform supports POSIX timers via timestruc_t. //define ACE_HAS_POSIX_TIME -#define ACE_LACKS_STRPTIME +#define ACE_HAS_STRPTIME +#define ACE_LACKS_NATIVE_STRPTIME // Platform supports the /proc file system. //define ACE_HAS_PROC_FS diff --git a/examples/Log_Msg/test_callback.cpp b/examples/Log_Msg/test_callback.cpp index 555402bde5b..fc29d20207a 100644 --- a/examples/Log_Msg/test_callback.cpp +++ b/examples/Log_Msg/test_callback.cpp @@ -9,11 +9,12 @@ // test_callback.cpp // // = DESCRIPTION -// This program tests the Log_Msg abstraction wrt writing to user -// defined callback objects. +// This program tests the <ACE_Log_Msg> class wrt writing to user +// defined callback objects. In particular, it tests to make sure +// that nested callbacks don't deadlock. // // = AUTHOR -// Irfan Pyarali +// Irfan Pyarali <irfan@cs.wustl.edu> // // ============================================================================ @@ -24,20 +25,53 @@ ACE_RCSID(Log_Msg, test_callback, "$Id$") class Logger : public ACE_Log_Msg_Callback { public: + Logger (int be_recursive = 1); + // Constructor sets whether we're testing "recursive" callback + // logging! + void log (ACE_Log_Record &log_record); // Logging callback + void verbose (int be_verbose); + +private: int verbose_logging_; - // Flag for verbose logging + // Flag for testing verbose logging. + + int recursive_; + // Flag for testing recursive callback logging. }; void +Logger::verbose (int be_verbose) +{ + this->verbose_logging_ = be_verbose; +} + +Logger::Logger (int be_recursive) + : recursive_ (be_recursive) +{ +} + +void Logger::log (ACE_Log_Record &log_record) { + int use_log_msg = 0; + if (this->recursive_) + { + this->recursive_ = 0; + use_log_msg = 1; + } + if (!this->verbose_logging_) { - ACE_OS::printf ("Logger::log -> %s\n", - log_record.msg_data ()); + if (use_log_msg) + ACE_DEBUG ((LM_DEBUG, + "Logger::log->%s\n", + log_record.msg_data ())); + else + ACE_OS::printf ("Recursive Logger callback = %s\n", + log_record.msg_data ()); } else { @@ -45,13 +79,21 @@ Logger::log (ACE_Log_Record &log_record) int result = log_record.format_msg (ACE_LOG_MSG->local_host (), ACE_LOG_MSG->flags (), verbose_msg); - if (result == 0) { - ACE_OS::printf ("Logger::log -> %s\n", - verbose_msg); - } + if (use_log_msg) + ACE_DEBUG ((LM_DEBUG, + "Logger::log->%s\n", + verbose_msg)); + else + ACE_OS::printf ("Recursive Logger callback = %s\n", + verbose_msg); + } } + + // Cleanup on the way out. + if (use_log_msg) + this->recursive_ = 1; } int @@ -59,56 +101,59 @@ main (int, char *[]) { // This message should show up in stderr. ACE_DEBUG ((LM_DEBUG, - "first message\n")); + "(%t) first message\n")); ACE_LOG_MSG->clr_flags (ACE_Log_Msg::STDERR); // This message should not show up anywhere. ACE_DEBUG ((LM_DEBUG, - "second message\n")); + "(%t) second message\n")); ACE_LOG_MSG->set_flags (ACE_Log_Msg::MSG_CALLBACK); // This message should not show up anywhere since no callback object // has been specified. ACE_DEBUG ((LM_DEBUG, - "third message\n")); + "(%t) third message\n")); - // Create a callback object. + // Create a callback object and make it "verbose". Logger logger; - logger.verbose_logging_ = 1; + logger.verbose (1); // Set the callback object. ACE_LOG_MSG->msg_callback (&logger); - // This message should show up in the logger. + // This message should show up via the Logger callback. ACE_DEBUG ((LM_DEBUG, - "forth message\n")); + "(%t) forth message\n")); ACE_LOG_MSG->set_flags (ACE_Log_Msg::VERBOSE_LITE); - // This message should show up in the logger (somewhat loudly). + // This message should show up via the Logger callback (somewhat + // verbosely). ACE_DEBUG ((LM_DEBUG, - "fifth message\n")); + "(%t) fifth message\n")); ACE_LOG_MSG->set_flags (ACE_Log_Msg::VERBOSE); - // This message should show up in the logger (really loudly). + // This message should show up via the Logger callback (really + // verbosely). ACE_DEBUG ((LM_DEBUG, - "sixth message\n")); + "(%t) sixth message\n")); - logger.verbose_logging_ = 0; + logger.verbose (0); - // This message should show up in the logger (not loudly). + // This message should show up via the Logger callback (not + // verbosely). ACE_DEBUG ((LM_DEBUG, - "seventh message\n")); + "(%t) seventh message\n")); ACE_LOG_MSG->set_flags (ACE_Log_Msg::STDERR); - // This message should show up in stderr and the logger. The one - // from the logger will not be loud, but the one from stderr should - // be loud. + // This message should show up in stderr and the Logger callback. + // The one from the Logger callback will not be verbose, but the one + // from stderr should be verbose. ACE_DEBUG ((LM_DEBUG, - "eight message\n")); + "(%t) eight message\n")); return 0; } diff --git a/tests/Cached_Accept_Conn_Test.cpp b/tests/Cached_Accept_Conn_Test.cpp index e040fdf18d6..83f47fdb74e 100644 --- a/tests/Cached_Accept_Conn_Test.cpp +++ b/tests/Cached_Accept_Conn_Test.cpp @@ -309,6 +309,9 @@ static int user_has_specified_iterations = 0; static size_t keep_handles_available = 100; static double purge_percentage = 20; static Caching_Strategy_Type caching_strategy_type = ACE_ALL; + +// For some strange reason this must *not* be static since otherwise +// certain versions of SunC++ will not link properly. int connection_accepted = 0; // On Win32, the handle gobbling doesn't work. Therefore, we need |