summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog32
-rw-r--r--ChangeLogs/ChangeLog-02a32
-rw-r--r--ChangeLogs/ChangeLog-03a32
-rw-r--r--THANKS1
-rw-r--r--ace/Local_Name_Space_T.cpp19
-rw-r--r--ace/Log_Msg.h1
-rw-r--r--ace/Logging_Strategy.cpp7
-rw-r--r--ace/Service_Manager.cpp41
-rw-r--r--ace/Service_Manager.h30
-rw-r--r--tests/Log_Msg_Test.cpp118
-rw-r--r--tests/Logging_Strategy_Test.cpp406
-rw-r--r--tests/MEM_Stream_Test.cpp2
-rw-r--r--tests/MM_Shared_Memory_Test.cpp2
-rw-r--r--tests/Makefile1
-rw-r--r--tests/Mem_Map_Test.cpp6
-rw-r--r--tests/Naming_Test.cpp2
-rw-r--r--tests/Process_Strategy_Test.cpp2
-rw-r--r--tests/Reactor_Timer_Test.cpp3
-rw-r--r--tests/SOCK_Connector_Test.cpp114
-rw-r--r--tests/Time_Service_Test.cpp2
-rw-r--r--tests/run_test.lst2
21 files changed, 718 insertions, 137 deletions
diff --git a/ChangeLog b/ChangeLog
index 848d367f741..72ad9293730 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,35 @@
+Sat Mar 10 07:05:16 2001 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu>
+
+ * tests: Added Logging_Strategy_Test.cpp. Thanks to Orlando
+ Ribeiro <oribeiro@inescporto.pt> for contributing this.
+
+ * tests/Makefile (BIN): Added Logging_Strategy_Test.
+
+ * tests/run_test.lst: Added Log_Msg_Test and
+ the new Logging_Strategy_Test.
+
+ * tests/Log_Msg_Test.cpp: Added ACE_TEXT macros to all the ACE_DEBUG and
+ ACE_ERROR calls.
+
+ * ace/Service_Manager.{h,cpp}: Refactored the request processing
+ code so that it's in a single place. Also, added support to
+ enable remote reconfiguration. Thanks to Mike Curtis
+ <mccurry@my-deja.com> for contributing this.
+
+ * ace/Logging_Strategy.cpp (parse_args): Fixed a mistaken
+ re-initialization of the thread_priority_mask_ and the
+ process_priority_mask_. Thanks to Martin Krumpolec
+ <krumpo@pobox.sk> for reporting this.
+
+ * ace/Local_Name_Space_T.cpp (create_manager_i): Fixed this code so that
+ it doesn't fail if run on a directory that doesn't support locks
+ (like some NFS mounts). Thanks to scott snyder
+ <snyder@fnal.gov> for reporting this.
+
+ * tests/SOCK_Connector_Test.cpp: Split up a loop so that the test
+ doesn't hang on RedHat Linux 7.0. Thanks to Michael Searles
+ <msearles@base16.com> for this fix.
+
Fri Mar 9 22:39:28 2001 Carlos O'Ryan <coryan@uci.edu>
* ace/Svc_Conf.h:
diff --git a/ChangeLogs/ChangeLog-02a b/ChangeLogs/ChangeLog-02a
index 848d367f741..72ad9293730 100644
--- a/ChangeLogs/ChangeLog-02a
+++ b/ChangeLogs/ChangeLog-02a
@@ -1,3 +1,35 @@
+Sat Mar 10 07:05:16 2001 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu>
+
+ * tests: Added Logging_Strategy_Test.cpp. Thanks to Orlando
+ Ribeiro <oribeiro@inescporto.pt> for contributing this.
+
+ * tests/Makefile (BIN): Added Logging_Strategy_Test.
+
+ * tests/run_test.lst: Added Log_Msg_Test and
+ the new Logging_Strategy_Test.
+
+ * tests/Log_Msg_Test.cpp: Added ACE_TEXT macros to all the ACE_DEBUG and
+ ACE_ERROR calls.
+
+ * ace/Service_Manager.{h,cpp}: Refactored the request processing
+ code so that it's in a single place. Also, added support to
+ enable remote reconfiguration. Thanks to Mike Curtis
+ <mccurry@my-deja.com> for contributing this.
+
+ * ace/Logging_Strategy.cpp (parse_args): Fixed a mistaken
+ re-initialization of the thread_priority_mask_ and the
+ process_priority_mask_. Thanks to Martin Krumpolec
+ <krumpo@pobox.sk> for reporting this.
+
+ * ace/Local_Name_Space_T.cpp (create_manager_i): Fixed this code so that
+ it doesn't fail if run on a directory that doesn't support locks
+ (like some NFS mounts). Thanks to scott snyder
+ <snyder@fnal.gov> for reporting this.
+
+ * tests/SOCK_Connector_Test.cpp: Split up a loop so that the test
+ doesn't hang on RedHat Linux 7.0. Thanks to Michael Searles
+ <msearles@base16.com> for this fix.
+
Fri Mar 9 22:39:28 2001 Carlos O'Ryan <coryan@uci.edu>
* ace/Svc_Conf.h:
diff --git a/ChangeLogs/ChangeLog-03a b/ChangeLogs/ChangeLog-03a
index 848d367f741..72ad9293730 100644
--- a/ChangeLogs/ChangeLog-03a
+++ b/ChangeLogs/ChangeLog-03a
@@ -1,3 +1,35 @@
+Sat Mar 10 07:05:16 2001 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu>
+
+ * tests: Added Logging_Strategy_Test.cpp. Thanks to Orlando
+ Ribeiro <oribeiro@inescporto.pt> for contributing this.
+
+ * tests/Makefile (BIN): Added Logging_Strategy_Test.
+
+ * tests/run_test.lst: Added Log_Msg_Test and
+ the new Logging_Strategy_Test.
+
+ * tests/Log_Msg_Test.cpp: Added ACE_TEXT macros to all the ACE_DEBUG and
+ ACE_ERROR calls.
+
+ * ace/Service_Manager.{h,cpp}: Refactored the request processing
+ code so that it's in a single place. Also, added support to
+ enable remote reconfiguration. Thanks to Mike Curtis
+ <mccurry@my-deja.com> for contributing this.
+
+ * ace/Logging_Strategy.cpp (parse_args): Fixed a mistaken
+ re-initialization of the thread_priority_mask_ and the
+ process_priority_mask_. Thanks to Martin Krumpolec
+ <krumpo@pobox.sk> for reporting this.
+
+ * ace/Local_Name_Space_T.cpp (create_manager_i): Fixed this code so that
+ it doesn't fail if run on a directory that doesn't support locks
+ (like some NFS mounts). Thanks to scott snyder
+ <snyder@fnal.gov> for reporting this.
+
+ * tests/SOCK_Connector_Test.cpp: Split up a loop so that the test
+ doesn't hang on RedHat Linux 7.0. Thanks to Michael Searles
+ <msearles@base16.com> for this fix.
+
Fri Mar 9 22:39:28 2001 Carlos O'Ryan <coryan@uci.edu>
* ace/Svc_Conf.h:
diff --git a/THANKS b/THANKS
index d6b7d30b190..4a14a0a1e1a 100644
--- a/THANKS
+++ b/THANKS
@@ -1172,6 +1172,7 @@ Tompa <safdsfd@adsffda.com>
Derek Horton <trohed@yahoo.com>
Shameek Basu <sbasu@ivast.com>
Dipti Jain <dijain@hss.hns.com>
+Eric Zuur <Eric.Zuur@meco.nl>
I would particularly like to thank Paul Stephenson, who worked with me
at Ericsson in the early 1990's. Paul devised the recursive Makefile
diff --git a/ace/Local_Name_Space_T.cpp b/ace/Local_Name_Space_T.cpp
index 7747e690076..1f4bd9b760f 100644
--- a/ace/Local_Name_Space_T.cpp
+++ b/ace/Local_Name_Space_T.cpp
@@ -420,17 +420,30 @@ ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::create_manager_i (void)
size_t length = 0;
length = sizeof lock_name_for_local_name_space / sizeof (ACE_TCHAR);
ACE_OS::strncpy (lock_name_for_local_name_space,
- ACE_LIB_TEXT ("name_space_"),
+ dir,
length);
+
+ ACE_OS::strncat (lock_name_for_local_name_space,
+ ACE_LIB_TEXT (ACE_DIRECTORY_SEPARATOR_STR),
+ length - ACE_OS::strlen (lock_name_for_local_name_space));
+ ACE_OS::strncat (lock_name_for_local_name_space,
+ ACE_LIB_TEXT ("name_space_"),
+ length - ACE_OS::strlen (lock_name_for_local_name_space));
ACE_OS::strncat (lock_name_for_local_name_space,
postfix,
- length - ACE_OS::strlen (ACE_LIB_TEXT ("name_space_")));
+ length - ACE_OS::strlen (lock_name_for_local_name_space));
length = sizeof lock_name_for_backing_store / sizeof (ACE_TCHAR);
ACE_OS::strncpy (lock_name_for_backing_store,
- ACE_LIB_TEXT ("backing_store_"),
+ dir,
length);
ACE_OS::strncat (lock_name_for_backing_store,
+ ACE_LIB_TEXT (ACE_DIRECTORY_SEPARATOR_STR),
+ length - ACE_OS::strlen (lock_name_for_backing_store));
+ ACE_OS::strncat (lock_name_for_backing_store,
+ ACE_LIB_TEXT ("backing_store_"),
+ length - ACE_OS::strlen (lock_name_for_backing_store));
+ ACE_OS::strncat (lock_name_for_backing_store,
postfix,
length - ACE_OS::strlen (ACE_LIB_TEXT ("backing_store_")));
diff --git a/ace/Log_Msg.h b/ace/Log_Msg.h
index 2e570ac9987..b0281eb2607 100644
--- a/ace/Log_Msg.h
+++ b/ace/Log_Msg.h
@@ -10,7 +10,6 @@
*/
//=============================================================================
-
#ifndef ACE_LOG_MSG_H
#define ACE_LOG_MSG_H
#include "ace/pre.h"
diff --git a/ace/Logging_Strategy.cpp b/ace/Logging_Strategy.cpp
index 69a271b0f13..6d8af666829 100644
--- a/ace/Logging_Strategy.cpp
+++ b/ace/Logging_Strategy.cpp
@@ -108,9 +108,10 @@ ACE_Logging_Strategy::parse_args (int argc, ACE_TCHAR *argv[])
ACE_TRACE ("ACE_Logging_Strategy::parse_args");
ACE_TCHAR *temp;
- // Perform data member initializations.
- this->thread_priority_mask_ = 0;
- this->process_priority_mask_ = 0;
+ // Perform data member initializations. BTW, do *not* initialize
+ // <thread_priority_mask_> or <process_priority_mask_> here to avoid
+ // unduing the behavior in <init>, where these are set by
+ // <ACE_Log_Msg::instance>.
this->flags_ = 0;
this->wipeout_logfile_ = 0;
this->count_ = 0;
diff --git a/ace/Service_Manager.cpp b/ace/Service_Manager.cpp
index e496ca0a7e9..b4aa50d45f7 100644
--- a/ace/Service_Manager.cpp
+++ b/ace/Service_Manager.cpp
@@ -223,6 +223,31 @@ ACE_Service_Manager::reconfigure_services (void)
sizeof ("done\n"));
}
+// isolate the request-processing code
+void
+ACE_Service_Manager::process_request (ACE_TCHAR *request)
+{
+ ACE_TRACE("ACE_Service_Manager::process_request");
+ char *p;
+
+ // Kill trailing newlines.
+ for (p = request;
+ (*p != '\0') && (*p != '\r') && (*p != '\n');
+ p++)
+ continue;
+
+ *p = '\0';
+
+ if (ACE_OS::strcmp (request, "help") == 0)
+ this->list_services ();
+ else if (ACE_OS::strcmp (request, "reconfigure") == 0)
+ this->reconfigure_services ();
+ else
+ ACE_Service_Config::process_directive (request);
+
+ // Additional management services may be handled here...
+}
+
// Accept new connection from client and carry out the service they
// request.
@@ -288,27 +313,13 @@ ACE_Service_Manager::handle_input (ACE_HANDLE)
/* NOTREACHED */
default:
{
- char *p;
-
- // Kill trailing newlines.
- for (p = request;
- (*p != '\0') && (*p != '\r') && (*p != '\n');
- p++)
- continue;
-
- *p = '\0';
-
ACE_Event_Handler *old_signal_handler = 0;
ACE_Reactor::instance ()->register_handler (SIGPIPE,
this,
0,
&old_signal_handler);
- if (ACE_OS::strcmp (request, "help") == 0)
- this->list_services ();
- else if (ACE_OS::strcmp (request, "reconfigure") == 0)
- this->reconfigure_services ();
- // Additional management services may be handled here...
+ this->process_request (request);
// Restore existing SIGPIPE handler
ACE_Reactor::instance ()->register_handler (SIGPIPE,
diff --git a/ace/Service_Manager.h b/ace/Service_Manager.h
index 7c0c5cbd10d..0ffb8aa9a9b 100644
--- a/ace/Service_Manager.h
+++ b/ace/Service_Manager.h
@@ -1,17 +1,15 @@
/* -*- C++ -*- */
-
//=============================================================================
/**
* @file Service_Manager.h
*
* $Id$
*
- * @author Doug Schmidt
+ * @author Doug Schmidt <schmidt@cs.wustl.edu>
*/
//=============================================================================
-
#ifndef ACE_SERVICE_MANAGER_H
#define ACE_SERVICE_MANAGER_H
#include "ace/pre.h"
@@ -32,12 +30,22 @@
* @brief Provide a standard ACE service for managing all the services
* configured in an <ACE_Service_Repository>.
*
- * This implementation is very simple. It just handles each
- * client request one at a time. Each request is associated
- * with a new connection, which is closed when the request is
- * processed. In addition, you must be using the singleton
- * <ACE_Reactor::instance> in order to trigger reconfigurations.
- * This scheme can certainly be improved.
+ * This implementation is simple and just handles each client
+ * request one at a time. There are currently 3 types of requests:
+ * + List services: If the string "help" is sent, return a list of all
+ * the services supported by the Service Configurator.
+ * + Reconfigure: If the string "reconfigure" is sent trigger a
+ * reconfiguration, which will re-read the local <svc.conf> file.
+ * + Process directive: If neither "help" nor "reconfigure" is sent,
+ * simply treat the incoming string as a process directive and pass
+ * it along to <ACE_Service_Config::process_directive>. This allows
+ * remote configuration via command-line instructions like
+ * $echo suspend Remote_Brdcast | telnet hostname 3911
+ *
+ * Each request is associated with a new connection, which is closed
+ * when the request is processed. In addition, you must be using the
+ * singleton <ACE_Reactor::instance> in order to trigger
+ * reconfigurations.
*/
class ACE_Export ACE_Service_Manager : public ACE_Service_Object
{
@@ -51,6 +59,7 @@ public:
protected:
// = Perform the various meta-services.
+
/// Trigger a remote reconfiguration of the Service Configurator.
virtual int reconfigure_services (void);
@@ -82,6 +91,9 @@ private:
virtual int handle_close (ACE_HANDLE fd, ACE_Reactor_Mask);
virtual int handle_signal (int signum, siginfo_t *, ucontext_t *);
+ /// Handle one request.
+ virtual void process_request (ACE_TCHAR *request);
+
/// Connection to the client (we only support one client connection
/// at a time).
ACE_SOCK_Stream client_stream_;
diff --git a/tests/Log_Msg_Test.cpp b/tests/Log_Msg_Test.cpp
index 99331ef2f6a..6e74f6373cd 100644
--- a/tests/Log_Msg_Test.cpp
+++ b/tests/Log_Msg_Test.cpp
@@ -32,7 +32,7 @@ static void
cleanup (void)
{
ACE_DEBUG ((LM_INFO,
- "cleanup hook (%P)!\n"));
+ ACE_TEXT ("cleanup hook (%P)!\n")));
}
static void
@@ -40,7 +40,7 @@ cause_error (void)
{
errno = EWOULDBLOCK;
ACE_ERROR ((LM_DEBUG,
- "would block\n"));
+ ACE_TEXT ("would block\n")));
}
class Logger : public ACE_Log_Msg_Callback
@@ -88,7 +88,7 @@ Logger::log (ACE_Log_Record &log_record)
{
if (use_log_msg)
ACE_DEBUG ((LM_DEBUG,
- "Logger::log->%s\n",
+ ACE_TEXT ("Logger::log->%s\n"),
log_record.msg_data ()));
#if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
else
@@ -108,7 +108,7 @@ Logger::log (ACE_Log_Record &log_record)
{
if (use_log_msg)
ACE_DEBUG ((LM_DEBUG,
- "Logger::log->%s\n",
+ ACE_TEXT ("Logger::log->%s\n"),
verbose_msg));
#if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
else
@@ -130,20 +130,20 @@ test_callbacks (void)
{
// This message should show up in stderr.
ACE_DEBUG ((LM_DEBUG,
- "(%t) first message\n"));
+ ACE_TEXT ("(%t) first message\n")));
ACE_LOG_MSG->clr_flags (ACE_Log_Msg::OSTREAM);
// This message should not show up anywhere.
ACE_DEBUG ((LM_DEBUG,
- "(%t) second message\n"));
+ ACE_TEXT ("(%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,
- "(%t) third message\n"));
+ ACE_TEXT ("(%t) third message\n")));
// Create a callback object and make it "verbose".
Logger logger;
@@ -154,28 +154,28 @@ test_callbacks (void)
// This message should show up via the Logger callback.
ACE_DEBUG ((LM_DEBUG,
- "(%t) forth message\n"));
+ ACE_TEXT ("(%t) forth message\n")));
ACE_LOG_MSG->set_flags (ACE_Log_Msg::VERBOSE_LITE);
// This message should show up via the Logger callback (somewhat
// verbosely).
ACE_DEBUG ((LM_DEBUG,
- "(%t) fifth message\n"));
+ ACE_TEXT ("(%t) fifth message\n")));
ACE_LOG_MSG->set_flags (ACE_Log_Msg::VERBOSE);
// This message should show up via the Logger callback (really
// verbosely).
ACE_DEBUG ((LM_DEBUG,
- "(%t) sixth message\n"));
+ ACE_TEXT ("(%t) sixth message\n")));
logger.verbose (0);
// This message should show up via the Logger callback (not
// verbosely).
ACE_DEBUG ((LM_DEBUG,
- "(%t) seventh message\n"));
+ ACE_TEXT ("(%t) seventh message\n")));
ACE_LOG_MSG->set_flags (ACE_Log_Msg::OSTREAM);
@@ -183,7 +183,7 @@ test_callbacks (void)
// The one from the Logger callback will not be verbose, but the one
// from stderr should be verbose.
ACE_DEBUG ((LM_DEBUG,
- "(%t) eighth message\n"));
+ ACE_TEXT ("(%t) eighth message\n")));
ACE_LOG_MSG->msg_callback (0);
}
@@ -196,7 +196,7 @@ test_log_msg_features (const ACE_TCHAR *program)
if (ACE_LOG_MSG->open (program) == -1)
ACE_ERROR ((LM_ERROR,
- "cannot open logger!!!\n"));
+ ACE_TEXT ("cannot open logger!!!\n")));
cause_error ();
@@ -204,17 +204,17 @@ test_log_msg_features (const ACE_TCHAR *program)
if (ACE_LOG_MSG->op_status () == -1
&& ACE_LOG_MSG->errnum () == EWOULDBLOCK)
ACE_DEBUG ((LM_DEBUG,
- "op_status and errnum work!\n"));
+ ACE_TEXT ("op_status and errnum work!\n")));
else
ACE_ERROR ((LM_ERROR,
- "op_status and errnum failed!\n"));
+ ACE_TEXT ("op_status and errnum failed!\n")));
const char *badname = "badname";
if (ACE_OS::open (badname,
O_RDONLY) == ACE_INVALID_HANDLE)
ACE_ERROR ((LM_ERROR,
- "%n: (%x), can't open %s%r\n",
+ ACE_TEXT ("%n: (%x), can't open %s%r\n"),
10000,
badname,
cleanup));
@@ -222,7 +222,7 @@ test_log_msg_features (const ACE_TCHAR *program)
// Exercise many different combinations of OSTREAM.
ACE_DEBUG ((LM_INFO,
- "%10f, %*s%s = %d\n",
+ ACE_TEXT ("%10f, %*s%s = %d\n"),
3.1416 * counter++,
8,
"",
@@ -233,7 +233,7 @@ test_log_msg_features (const ACE_TCHAR *program)
ACE_LOG_MSG->msg_ostream (ace_file_stream::instance ()->output_file ());
ACE_DEBUG ((LM_INFO,
- "%10f, %*s%s = %d\n",
+ ACE_TEXT ("%10f, %*s%s = %d\n"),
3.1416 * counter,
8,
"",
@@ -244,7 +244,7 @@ test_log_msg_features (const ACE_TCHAR *program)
// The next two messages shouldn't print.
ACE_DEBUG ((LM_INFO,
- "%10f, %*s%s = %d\n",
+ ACE_TEXT ("%10f, %*s%s = %d\n"),
3.1416 * counter,
8,
"",
@@ -252,7 +252,7 @@ test_log_msg_features (const ACE_TCHAR *program)
10000 * counter++));
ACE_DEBUG ((LM_INFO,
- "%10f, %*s%s = %d\n",
+ ACE_TEXT ("%10f, %*s%s = %d\n"),
3.1416 * counter,
8,
"",
@@ -261,7 +261,7 @@ test_log_msg_features (const ACE_TCHAR *program)
ACE_LOG_MSG->set_flags (ACE_Log_Msg::OSTREAM);
ACE_DEBUG ((LM_INFO,
- "%10f, %*s%s = %d\n",
+ ACE_TEXT ("%10f, %*s%s = %d\n"),
3.1416 * counter,
8,
"",
@@ -284,9 +284,9 @@ test_log_msg_features (const ACE_TCHAR *program)
ACE_Log_Msg::PROCESS);
ACE_DEBUG ((LM_INFO,
- "This LM_INFO message should not print!\n"));
+ ACE_TEXT ("This LM_INFO message should not print!\n")));
ACE_DEBUG ((LM_DEBUG,
- "This LM_DEBUG message should not print!\n"));
+ ACE_TEXT ("This LM_DEBUG message should not print!\n")));
ACE_SET_BITS (priority_mask,
LM_INFO);
@@ -294,18 +294,18 @@ test_log_msg_features (const ACE_TCHAR *program)
ACE_Log_Msg::PROCESS);
ACE_DEBUG ((LM_INFO,
- "This LM_INFO message should print!\n"));
+ ACE_TEXT ("This LM_INFO message should print!\n")));
ACE_DEBUG ((LM_DEBUG,
- "This LM_DEBUG message should not print!\n"));
+ ACE_TEXT ("This LM_DEBUG message should not print!\n")));
ACE_CLR_BITS (priority_mask, LM_INFO);
ACE_LOG_MSG->priority_mask (priority_mask,
ACE_Log_Msg::PROCESS);
ACE_DEBUG ((LM_INFO,
- "This LM_INFO message should not print!\n"));
+ ACE_TEXT ("This LM_INFO message should not print!\n")));
ACE_DEBUG ((LM_DEBUG,
- "This LM_DEBUG message should not print!\n"));
+ ACE_TEXT ("This LM_DEBUG message should not print!\n")));
}
static int
@@ -313,13 +313,13 @@ test_ostream (void)
{
// This message should show up in the log file.
ACE_DEBUG ((LM_DEBUG,
- "first message\n"));
+ ACE_TEXT ("first message\n")));
ACE_LOG_MSG->clr_flags (ACE_Log_Msg::OSTREAM);
// This message should not show up anywhere.
ACE_DEBUG ((LM_DEBUG,
- "second message\n"));
+ ACE_TEXT ("second message\n")));
ACE_LOG_MSG->set_flags (ACE_Log_Msg::OSTREAM);
@@ -337,7 +337,7 @@ test_ostream (void)
// This message should show up in the ostream.
ACE_DEBUG ((LM_DEBUG,
- "fourth message\n"));
+ ACE_TEXT ("fourth message\n")));
ACE_FILE_Connector connector;
ACE_FILE_IO file;
@@ -345,14 +345,14 @@ test_ostream (void)
// Open up the file.
if (connector.connect (file,
ACE_FILE_Addr (filename)) == -1)
- {
- // Set the ostream back to NULL to prevent "later functions using myostream".
- ACE_LOG_MSG->msg_ostream (ace_file_stream::instance ()->output_file ());
+ {
+ // Set the ostream back to NULL to prevent "later functions using myostream".
+ ACE_LOG_MSG->msg_ostream (ace_file_stream::instance ()->output_file ());
ACE_ERROR_RETURN ((LM_ERROR,
- "connect failed for %p\n",
- filename),
- 1);
- }
+ ACE_TEXT ("connect failed for %p\n"),
+ filename),
+ 1);
+ }
// Unlink this file right away so that it is automatically removed
// when the process exits.Ignore error returns in case this operation
@@ -361,14 +361,14 @@ test_ostream (void)
ACE_FILE_Info info;
if (file.get_info (info) == -1)
- {
- // Set the ostream back to NULL to prevent "later functions using myostream".
- ACE_LOG_MSG->msg_ostream (ace_file_stream::instance ()->output_file ());
- ACE_ERROR_RETURN ((LM_ERROR,
- "get_info failed on %p\n",
- filename),
- -1);
- }
+ {
+ // Set the ostream back to NULL to prevent "later functions using myostream".
+ ACE_LOG_MSG->msg_ostream (ace_file_stream::instance ()->output_file ());
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("get_info failed on %p\n"),
+ filename),
+ -1);
+ }
// Allocate the input buffer
char *buffer;
@@ -382,15 +382,15 @@ test_ostream (void)
ssize_t size = file.recv (buffer,
info.size_);
if (size != info.size_)
- {
- // Set the ostream back to NULL to prevent "later functions using myostream".
- ACE_LOG_MSG->msg_ostream (ace_file_stream::instance ()->output_file ());
- ACE_ERROR_RETURN ((LM_ERROR,
- "Read %d bytes, rather than expected %d bytes\n",
- size,
- info.size_),
- -1);
- }
+ {
+ // Set the ostream back to NULL to prevent "later functions using myostream".
+ ACE_LOG_MSG->msg_ostream (ace_file_stream::instance ()->output_file ());
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Read %d bytes, rather than expected %d bytes\n",)
+ size,
+ info.size_),
+ -1);
+ }
// Make sure to NUL-terminate this turkey!
buffer[size] = '\0';
@@ -398,7 +398,7 @@ test_ostream (void)
ACE_LOG_MSG->msg_ostream (ace_file_stream::instance ()->output_file ());
ACE_DEBUG ((LM_DEBUG,
- "%s",
+ ACE_TEXT ("%s"),
buffer));
#endif /* ACE_LACKS_IOSTREAM_TOTALLY */
@@ -406,7 +406,7 @@ test_ostream (void)
// This message should show up in stderr and the ostream (without
// ACE_LACKS_IOSTREAM_TOTALLY).
ACE_DEBUG ((LM_DEBUG,
- "fifth message\n"));
+ ACE_TEXT ("fifth message\n")));
return 0;
}
@@ -418,20 +418,20 @@ main (int, ACE_TCHAR *argv[])
{
ACE_START_TEST (ACE_TEXT ("Log_Msg_Test"));
ACE_DEBUG ((LM_DEBUG,
- "**** running ostream test\n"));
+ ACE_TEXT ("**** running ostream test\n")));
// Test the <ACE_Log_Msg> abstraction wrt writing to stderr and to a
// file.
test_ostream ();
ACE_DEBUG ((LM_DEBUG,
- "**** running callback test\n"));
+ ACE_TEXT ("**** running callback test\n")));
// Test the <ACE_Log_Msg> callback mechanism.
test_callbacks ();
ACE_DEBUG ((LM_DEBUG,
- "**** running features test\n"));
+ ACE_TEXT ("**** running features test\n")));
// Test various features of the <ACE_Log_Msg>.
test_log_msg_features (argv[0]);
diff --git a/tests/Logging_Strategy_Test.cpp b/tests/Logging_Strategy_Test.cpp
new file mode 100644
index 00000000000..7fa592dbca1
--- /dev/null
+++ b/tests/Logging_Strategy_Test.cpp
@@ -0,0 +1,406 @@
+// $Id$
+
+//==========================================================================
+//
+// = LIBRARY
+// tests
+//
+// = FILENAME
+// Logging_Strategy_Test.cpp
+//
+// = DESCRIPTION
+// This program tests the <ACE_Logging_Strategy> class in various ways
+// and also illustrates many of the features of the <ACE_Log_Msg>
+//
+// = AUTHOR
+// Orlando Ribeiro <oribeiro@inescporto.pt>
+//
+//==========================================================================
+
+#include "ace/OS.h"
+#include "ace/Service_Config.h"
+#include "ace/Thread_Manager.h"
+#include <ace/Get_Opt.h>
+#include "test_config.h"
+
+ACE_RCSID(tests, Logging_Strategy_Test, "Logging_Strategy_Test.cpp,v 1.00 2001/02/19 05:17:39 oribeiro Exp")
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+// Considering UNIX OS to be default. On Win32 platforms, the symbols
+// are got form the .exe as one cant have .exe and .dll for the same
+// .cpp. Also, on Win32 platforms one cant use the .obj to obtain
+// symbols dynamically at runtime.
+
+#if defined (ACE_WIN32)
+# define OBJ_SUFFIX ACE_TEXT (".exe")
+# define OBJ_PREFIX ACE_TEXT ("")
+#else
+# define OBJ_SUFFIX ACE_DLL_SUFFIX
+# define OBJ_PREFIX "./" ACE_DLL_PREFIX
+#endif /*ACE_WIN32*/
+
+ACE_TCHAR const *
+cdecl_decoration (ACE_TCHAR const *func_name)
+{
+#if defined (__BORLANDC__)
+ static ACE_TCHAR decorated_func_name[10*1024];
+ ACE_OS::sprintf (decorated_func_name,
+ ACE_TEXT ("_%s"),
+ func_name);
+ return decorated_func_name;
+#else
+ return func_name;
+#endif /* __BORLANDC__ */
+}
+
+/ Global variables.
+static ACE_TCHAR *file_name;
+static int max_size_files = 0;
+static int max_num_files = 0;
+static int interval_time = 0;
+static int order_state = 0;
+static int num_files = 0;
+
+void
+run_reactor (void *)
+{
+ ACE_Reactor::instance ()->owner (ACE_Thread_Manager::instance ()->thr_self ());
+ ACE_Reactor::instance ()->run_event_loop ();
+}
+
+// Initiate the cycle of messages.
+
+static
+void print_till_death (void)
+{
+ ACE_DEBUG ((LM_DEBUG,
+ "\n-> start generating messages... \n"));
+ ACE_LOG_MSG->clr_flags (ACE_Log_Msg::STDERR);
+
+ for (int i = 0; i < 1000; i++)
+ {
+ if (i % 50 == 0)
+ ACE_OS::sleep (1);
+
+ if (i == 0)
+ ACE_DEBUG ((LM_DEBUG,
+ " (%t) (%D) message\n"));
+ else
+ ACE_DEBUG ((LM_DEBUG,
+ " (%t) %d message\n",
+ i));
+ }
+ ACE_Reactor::instance ()->end_event_loop ();
+
+ ACE_LOG_MSG->set_flags (ACE_Log_Msg::STDERR);
+ ACE_DEBUG ((LM_DEBUG,
+ "-< generating messages finished \n\n"));
+}
+
+// count the generated files
+void
+count_files (void)
+{
+ int i = 0;
+ int error = 0;
+ FILE *stream;
+ ACE_TCHAR backup_ct[MAXPATHLEN+1];
+ ACE_DEBUG ((LM_DEBUG,
+ "-> start counting...\n"));
+
+ do
+ {
+ if (i == 0)
+ ACE_OS::sprintf (backup_ct,
+ "%s",
+ file_name);
+ else
+ ACE_OS::sprintf (backup_ct,
+ "%s.%d",
+ file_name,
+ i);
+
+ stream = ACE_OS::fopen (backup_ct, "r");
+ if (stream == 0)
+ error = 1;
+ else
+ {
+ i++;
+ ACE_OS::fclose (stream);
+ }
+
+ }
+ while (error != 1);
+
+ num_files = i;
+
+ if (max_num_files !=0)
+ {
+ if (max_num_files != num_files)
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Creating files...Failed! Imput value=%d, Checked value=%d"),
+ max_num_files,
+ num_files));
+ else
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT (" Creating files...OK! Imput value=%d, Checked value=%d"),
+ max_num_files,
+ num_files));
+ }
+ else
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT (" The number of files generated is: %d"),
+ num_files));
+
+ ACE_DEBUG ((LM_DEBUG,
+ "\n-< counting finished... \n"));
+}
+
+// get the file statistics
+static int
+get_statistic (char *f_name)
+{
+ struct stat buf;
+ int result;
+
+ // Get data associated with "file_name":
+ result = ACE_OS::stat (f_name, &buf);
+
+ // Check if statistics are valid:
+ if (result != 0)
+ ACE_OS::perror ("\nProblem getting information");
+ else
+ {
+ // Output some of the statistics:
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT (" File name : %s\n"),
+ f_name));
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT (" File size (B): %d\n"),
+ buf.st_size));
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT (" Time modified : %s\n"),
+ ACE_OS::ctime (&buf.st_mtime)));
+ }
+ return buf.st_mtime;
+}
+
+// analyse the file order
+static void
+order (void)
+{
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("\n-> start testing order... \n")));
+
+ if (num_files <= 2)
+ {
+ if (num_files == 1)
+ get_statistic (file_name);
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT (" Ordering...OK! - Only %d file (s) was (were) generated"),
+ num_files));
+ }
+ else
+ {
+ int tm_bk_1, tm_bk_2;
+ ACE_TCHAR backup_1[MAXPATHLEN+1];
+ ACE_TCHAR backup_2[MAXPATHLEN+1];
+ ACE_OS::sprintf (backup_1,
+ ACE_TEXT ("%s.%d"),
+ file_name,
+ 1);
+ ACE_OS::sprintf (backup_2,
+ ACE_TEXT ("%s.%d"),
+ file_name,
+ num_files - 1);
+
+ tm_bk_1 = get_statistic (backup_1);
+ tm_bk_2 = get_statistic (backup_2);
+
+ if ((tm_bk_1 > tm_bk_2) && !order_state)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT (" %s (newest) ; %s (oldest)\n"),
+ backup_1,
+ backup_2));
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT (" Ordering...OK!")));
+ }
+ else
+ {
+ if ((tm_bk_1 < tm_bk_2) && order_state)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT (" %s (newest) ; %s (oldest)\n"),
+ backup_2,
+ backup_1));
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT (" Ordering...OK!")));
+ }
+ else
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT (" Ordering...FAILED! - The files are disorderly")));
+ }
+ }
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("\n-< testing order finished...\n\n")));
+}
+
+// remove log_files
+static void
+remove_files (void)
+{
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("\n-> removing existent files...\n")));
+
+ int error = 0;
+ int test;
+ int i = 0;
+ ACE_TCHAR backup[MAXPATHLEN+1];
+
+ do
+ {
+ i++;
+ ACE_OS::sprintf (backup,
+ ACE_TEXT ("%s.%d"),
+ file_name,
+ i);
+ test = ACE_OS::unlink (backup);
+ if (test != 0)
+ error = 1;
+
+ }
+ while (error != 1);
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("-< removing existent files finished... \n\n")));
+}
+
+static int
+parse_args (int argc, char* argv [])
+{
+ ACE_OS::printf ("Specifications:\n");
+ ACE_Get_Opt get_opt (argc, argv, "s:i:m:f:n:o");
+ int c;
+
+ while ((c = get_opt ()) != EOF)
+ {
+ switch (c)
+ {
+ case 's':
+ file_name = get_opt.optarg;
+ ACE_OS::printf ("File name: %s\n", file_name);
+ break;
+
+ case 'i':
+ interval_time = atoi (get_opt.optarg);
+ ACE_OS::printf ("Interval time (s): %d\n", interval_time);
+ break;
+
+ case 'm':
+ max_size_files = atoi (get_opt.optarg);
+ ACE_OS::printf ("Maximum size (KB): %d\n", max_size_files);
+ break;
+
+ case 'f':
+ ACE_OS::printf ("Modes: %s\n", get_opt.optarg);
+ break;
+
+ case 'n':
+ max_num_files = atoi (get_opt.optarg);
+ ACE_OS::printf ("Maximum files number: %d\n", max_num_files);
+ break;
+
+ case 'o':
+ ACE_OS::printf ("Ordering files activated\n");
+ order_state = 1;
+ break;
+
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("usage: [-s]<file_name>")
+ ACE_TEXT ("[-i]<sample_interval> [-m]<max_size> [-f]<msg_flags> [-n]<num_files> [-o]\n")
+ ACE_TEXT ("\t-s: Specify the name of the log files.\n")
+ ACE_TEXT ("\t-i: Define the sample interval in secs.\n")
+ ACE_TEXT ("\t-m: Define the max size for the log_files in KB.\n")
+ ACE_TEXT ("\t-f: Indicates the Log_Msg flags.\n")
+ ACE_TEXT ("\t-n: Define the maximum number of log_files.\n")
+ ACE_TEXT ("\t-o: If activated puts the log_files ordered.\n")),
+ -1);
+ /* NOTREACHED */
+ break;
+ }
+ }
+
+ return 0;
+}
+
+int main (int argc, char *argv[])
+{
+ ACE_START_TEST (ACE_TEXT ("Logging_Strategy_Test"));
+
+ // Protection against this test being run on platforms not supporting Dlls.
+#if defined (ACE_WIN32) || defined (ACE_HAS_SVR4_DYNAMIC_LINKING) || \
+ defined (__hpux)
+
+ // Implement the dynamic entries via main arguments
+ ACE_LOG_MSG -> open (argv[0]);
+
+ if (parse_args (argc, argv) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Invalid command-line parameters.\n"),
+ 1);
+
+ ACE_TCHAR arg_str[250];
+ sprintf (arg_str,
+ "dynamic Logger Service_Object *ACE:_make_ACE_Logging_Strategy()\" ");
+
+ for(int i=1; i<argc;i++)
+ {
+ ACE_OS_String::strcat(arg_str,argv[i]);
+ ACE_OS_String::strcat(arg_str, " ");
+ }
+
+ ACE_OS_String::ACE_OS_String::strcat (arg_str, " \"");
+
+ if (ACE_Service_Config::process_directive (arg_str) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Error opening _make_Detail_Log_Strategy object.\n"),
+ 1);
+
+ //launch a new Thread
+ if (ACE_Thread_Manager::instance ()->spawn (ACE_THR_FUNC (run_reactor)) < 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Spawning Reactor.\n"),
+ 1);
+
+ // remove the existent files
+ remove_files ();
+
+ // function to print the message
+ print_till_death ();
+
+ // counts the generated files
+ count_files ();
+
+ // get the file order
+ order ();
+
+ if (ACE_Reactor::instance ()->end_event_loop ())
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Error ending reactor.\n"),
+ 1);
+#else
+ ACE_ERROR ((LM_INFO,
+ ACE_TEXT ("DLLs not supported on this platform\n")));
+#endif /* ACE_WIN32 || ACE_HAS_SVR4_DYNAMIC_LINKING || __hpux */
+
+ ACE_END_TEST;
+ return 0;
+}
+
+
diff --git a/tests/MEM_Stream_Test.cpp b/tests/MEM_Stream_Test.cpp
index f60af4d2b95..dfdc7d4e560 100644
--- a/tests/MEM_Stream_Test.cpp
+++ b/tests/MEM_Stream_Test.cpp
@@ -75,7 +75,7 @@ Echo_Handler::handle_input (ACE_HANDLE)
ACE_TCHAR return_buf[MAXPATHLEN];
ACE_OS::strcpy (return_buf, this->name_);
- ACE_OS::strcat (return_buf, buf);
+ ACE_OS_String::strcat (return_buf, buf);
len = (ACE_OS::strlen (return_buf) + 1) * sizeof (ACE_TCHAR);
if (this->peer ().send (return_buf, len) != len)
diff --git a/tests/MM_Shared_Memory_Test.cpp b/tests/MM_Shared_Memory_Test.cpp
index 4366a137128..eab193fc4fd 100644
--- a/tests/MM_Shared_Memory_Test.cpp
+++ b/tests/MM_Shared_Memory_Test.cpp
@@ -197,7 +197,7 @@ main (int, ACE_TCHAR *[])
ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Temporary path too long\n")), -1);
// Add the filename to the end
- ACE_OS::strcat (temp_file, ACE_TEXT ("mm_shared_mem_testXXXXXX"));
+ ACE_OS_String::strcat (temp_file, ACE_TEXT ("mm_shared_mem_testXXXXXX"));
// Store in the global variable.
shm_key = temp_file;
diff --git a/tests/Makefile b/tests/Makefile
index beae3247d01..3f765a32ac2 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -40,6 +40,7 @@ BIN = Aio_Platform_Test \
IOStream_Test \
Lazy_Map_Manager_Test \
Log_Msg_Test \
+ Logging_Strategy_Test \
Malloc_Test \
Map_Test \
Map_Manager_Test \
diff --git a/tests/Mem_Map_Test.cpp b/tests/Mem_Map_Test.cpp
index c679c8a91f0..c7ac0532c6c 100644
--- a/tests/Mem_Map_Test.cpp
+++ b/tests/Mem_Map_Test.cpp
@@ -128,9 +128,9 @@ main (int, ACE_TCHAR *[])
ACE_OS::strcpy (temp_file2, test_file);
// Add the filenames to the end
- ACE_OS::strcat (test_file, ACE_TEXT ("ace_mem_map_test"));
- ACE_OS::strcat (temp_file1, ACE_TEXT ("ace_mem_map_temp_1"));
- ACE_OS::strcat (temp_file2, ACE_TEXT ("ace_mem_map_temp_2"));
+ ACE_OS_String::strcat (test_file, ACE_TEXT ("ace_mem_map_test"));
+ ACE_OS_String::strcat (temp_file1, ACE_TEXT ("ace_mem_map_temp_1"));
+ ACE_OS_String::strcat (temp_file2, ACE_TEXT ("ace_mem_map_temp_2"));
// First create a test file to work on
diff --git a/tests/Naming_Test.cpp b/tests/Naming_Test.cpp
index 8998fab053f..b763564772d 100644
--- a/tests/Naming_Test.cpp
+++ b/tests/Naming_Test.cpp
@@ -198,7 +198,7 @@ main (int argc, ACE_TCHAR *argv[])
{
ACE_OS::strcpy (temp_file, ACE::basename (name_options->process_name (),
ACE_DIRECTORY_SEPARATOR_CHAR));
- ACE_OS::strcat (temp_file, ACE_TEXT ("XXXXXX"));
+ ACE_OS_String::strcat (temp_file, ACE_TEXT ("XXXXXX"));
// Set the database name using mktemp to generate a unique file name
name_options->database (ACE_OS::mktemp (temp_file));
diff --git a/tests/Process_Strategy_Test.cpp b/tests/Process_Strategy_Test.cpp
index 361678b51dd..321b9aa311e 100644
--- a/tests/Process_Strategy_Test.cpp
+++ b/tests/Process_Strategy_Test.cpp
@@ -200,7 +200,7 @@ Options::parse_args (int argc, ACE_TCHAR *argv[])
ACE_TEXT ("Temporary path too long\n")),
-1);
- ACE_OS::strcat (this->filename_, ACE_TEXT ("process_strategy_test_temp"));
+ ACE_OS_String::strcat (this->filename_, ACE_TEXT ("process_strategy_test_temp"));
for (int c; (c = get_opt ()) != -1; )
switch (c)
diff --git a/tests/Reactor_Timer_Test.cpp b/tests/Reactor_Timer_Test.cpp
index 106af0e1727..62001142c91 100644
--- a/tests/Reactor_Timer_Test.cpp
+++ b/tests/Reactor_Timer_Test.cpp
@@ -240,7 +240,8 @@ main (int argc, ACE_TCHAR *[])
if (argc > 1)
{
- ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Running with high-res timer queue\n")));
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Running with high-res timer queue\n")));
ACE_Reactor *r = ACE_Reactor::instance ();
(void) ACE_High_Res_Timer::global_scale_factor ();
r->timer_queue ()->gettimeofday (&ACE_High_Res_Timer::gettimeofday_hr);
diff --git a/tests/SOCK_Connector_Test.cpp b/tests/SOCK_Connector_Test.cpp
index 353f73af251..945b3935033 100644
--- a/tests/SOCK_Connector_Test.cpp
+++ b/tests/SOCK_Connector_Test.cpp
@@ -1,6 +1,6 @@
// $Id$
-// ============================================================================
+// ==========================================================================
//
// = LIBRARY
// tests
@@ -15,7 +15,7 @@
// = AUTHOR
// Steve Huston <shuston@riverace.com>
//
-// ============================================================================
+// ==========================================================================
#include "test_config.h"
#include "ace/OS.h"
@@ -23,27 +23,38 @@
#include "ace/SOCK_Connector.h"
#include "ace/SOCK_Stream.h"
-ACE_RCSID(tests, SOCK_Connector_Test, "$Id$")
+ACE_RCSID(tests, SOCK_Connector_Test, "SOCK_Connector_Test.cpp,v 4.34 2000/04/23 21:29:17 brunsch Exp")
+
+// Host candidate list
+struct Host_Candidate
+{
+ ACE_TCHAR host_name[MAXHOSTNAMELEN];
+};
+
+const int MAX_CANDIDATES = 50;
+Host_Candidate candidate[MAX_CANDIDATES];
#if !defined (ACE_LACKS_GETHOSTENT)
-// Determine if a host exists, is reachable, and is up.
-// Attempt a blocking connection to it; if it succeeds,
-// then the host exists, is reachable, and is up.
+// Determine if a host exists, is reachable, and is up. Attempt a
+// blocking connection to it; if it succeeds, then the host exists, is
+// reachable, and is up.
+
static u_int
host_is_up (ACE_TCHAR hostname[])
{
ACE_SOCK_Connector con;
ACE_SOCK_Stream sock;
- // The ACE_INET_Addr construction causes gethostbyname_r
- // to be called, so we need to copy the hostname.
+ // The ACE_INET_Addr construction causes gethostbyname_r to be
+ // called, so we need to copy the hostname.
ACE_TCHAR test_host[MAXHOSTNAMELEN];
ACE_OS::strcpy (test_host, hostname);
ACE_INET_Addr another_host ((u_short) 7, test_host);
ACE_Time_Value timeout_value (5);
- const int status = con.connect (sock, another_host, &timeout_value);
-
+ const int status = con.connect (sock,
+ another_host,
+ &timeout_value);
sock.close ();
return status == 0 ? 1 : 0;
}
@@ -80,14 +91,20 @@ find_another_host (ACE_TCHAR other_host[])
// @@ We really need to add wrappers for these hostent methods.
- // AIX 4.3 has problems with DNS usage when sethostent(1) is called -
- // further DNS lookups don't work at all.
+ // AIX 4.3 has problems with DNS usage when sethostent(1) is
+ // called - further DNS lookups don't work at all.
#if defined (ACE_AIX_MINOR_VERS) && (ACE_AIX_MINOR_VERS == 3)
sethostent (0);
#else
sethostent (1);
-#endif
+#endif /* (ACE_AIX_MINOR_VERS) && (ACE_AIX_MINOR_VERS == 3) */
+ int candidate_count = 0;
+
+ // Accumulate candidates first. There is some interaction on
+ // Linux systems between <gethostent> and <gethostbyname_r>
+ // (called by ACE_INET_Addr in host_is_up) This otherwise causes
+ // an infinite loop on Linux --mas 03-08-2001
while ((h = gethostent ()) != NULL)
{
if (ACE_OS::strcmp (h->h_name, ACE_DEFAULT_SERVER_HOST) == 0)
@@ -97,15 +114,24 @@ find_another_host (ACE_TCHAR other_host[])
continue;
// If not me.
- if (ACE_OS::strcmp (h->h_name, other_host) != 0 &&
- ACE_OS::strcmp (h->h_name, un.nodename) != 0 )
+ if (ACE_OS::strcmp (h->h_name, other_host) != 0
+ && ACE_OS::strcmp (h->h_name, un.nodename) != 0)
+ {
+ ACE_OS::strcpy (candidate[candidate_count].host_name,
+ h->h_name);
+ if (candidate_count++ >= MAX_CANDIDATES)
+ break;
+ }
+ }
+
+ // Now try to connect to candidates
+ for (int i = 0; i < candidate_count; i++)
+ {
+ if (host_is_up (candidate[i].host_name))
{
- if (host_is_up (h->h_name))
- {
- ACE_OS::strcpy (other_host, h->h_name);
- break;
- }
- }
+ ACE_OS::strcpy (other_host, candidate[i].host_name);
+ break;
+ }
}
endhostent ();
@@ -114,9 +140,7 @@ find_another_host (ACE_TCHAR other_host[])
ACE_OS::strcpy (cached_other_host, other_host);
}
else
- {
- ACE_OS::strcpy (other_host, cached_other_host);
- }
+ ACE_OS::strcpy (other_host, cached_other_host);
}
static int
@@ -130,11 +154,16 @@ fail_no_listener_nonblocking (void)
ACE_Time_Value nonblock (0, 0);
find_another_host (test_host);
- ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Testing to host \"%s\"\n"), test_host));
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Testing to host \"%s\"\n"),
+ test_host));
+
if (nobody_home.set ((u_short) 42000, test_host) == -1)
{
- ACE_ERROR ((LM_ERROR, ACE_TEXT ("Host lookup for %s %p\n"),
- test_host, ACE_TEXT ("failed")));
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Host lookup for %s %p\n"),
+ test_host,
+ ACE_TEXT ("failed")));
return -1;
}
@@ -160,7 +189,8 @@ fail_no_listener_nonblocking (void)
}
else
{
- ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%p\n"),
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("%p\n"),
ACE_TEXT ("Proper fail")));
status = 0;
}
@@ -182,11 +212,12 @@ fail_no_listener_nonblocking (void)
// This test tries to hit a port that's listening. Echo (7) is pretty
-// popular. Just in case, though, it won't report a failure if it gets
-// "refused" (no listener) since the real fixed bug this is testing is
-// a returned error of EWOULDBLOCK when the connect really did work.
-// That was a side-affect of how ACE::handle_timed_complete does checks
-// on some systems.
+// popular. Just in case, though, it won't report a failure if it
+// gets "refused" (no listener) since the real fixed bug this is
+// testing is a returned error of EWOULDBLOCK when the connect really
+// did work. That was a side-affect of how
+// <ACE::handle_timed_complete> does checks on some systems.
+
static int
succeed_nonblocking (void)
{
@@ -198,11 +229,15 @@ succeed_nonblocking (void)
ACE_Time_Value nonblock (0, 0);
find_another_host (test_host);
- ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Testing to host \"%s\"\n"), test_host));
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Testing to host \"%s\"\n"),
+ test_host));
if (echo_server.set ((u_short) 7, test_host) == -1)
{
- ACE_ERROR ((LM_ERROR, ACE_TEXT ("Host lookup for %s %p\n"),
- test_host, ACE_TEXT ("failed")));
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Host lookup for %s %p\n"),
+ test_host,
+ ACE_TEXT ("failed")));
return -1;
}
status = con.connect (sock, echo_server, &nonblock);
@@ -226,7 +261,8 @@ succeed_nonblocking (void)
if (errno == ECONNREFUSED || errno == ENOTCONN)
status = 0;
- ACE_DEBUG ((LM_DEBUG, ACE_TEXT("%p\n"),
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT("%p\n"),
ACE_TEXT("connect:complete")));
}
else
@@ -240,7 +276,6 @@ succeed_nonblocking (void)
return status;
}
-
int
main (int, ACE_TCHAR *[])
{
@@ -257,3 +292,6 @@ main (int, ACE_TCHAR *[])
ACE_END_TEST;
return status;
}
+
+
+
diff --git a/tests/Time_Service_Test.cpp b/tests/Time_Service_Test.cpp
index 46f10b82542..a479a5ee16e 100644
--- a/tests/Time_Service_Test.cpp
+++ b/tests/Time_Service_Test.cpp
@@ -65,7 +65,7 @@ main (int, ACE_TCHAR *[])
}
// Add the filename to the end
- ACE_OS::strcat (backing_store,
+ ACE_OS_String::strcat (backing_store,
ACE_TEXT ("ace-malloc-XXXXXX"));
#endif /* ACE_DEFAULT_BACKING_STORE */
diff --git a/tests/run_test.lst b/tests/run_test.lst
index 473dca7ef1d..04ce31ea901 100644
--- a/tests/run_test.lst
+++ b/tests/run_test.lst
@@ -44,6 +44,8 @@ Hash_Map_Bucket_Iterator_Test
High_Res_Timer_Test
IOStream_Test
Lazy_Map_Manager_Test
+Log_Msg_Test
+Logging_Strategy_Test
Map_Manager_Test
Map_Test
MEM_Stream_Test: !Linux