summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Huston <shuston@riverace.com>2001-07-25 20:33:08 +0000
committerSteve Huston <shuston@riverace.com>2001-07-25 20:33:08 +0000
commit775c50fc8334646a9c52453ea18e588470218294 (patch)
treee91c7f97095954eb38b278b9680335f858427edf
parente78c73d1cee29027706b23b9560e4109442e6246 (diff)
downloadATCD-775c50fc8334646a9c52453ea18e588470218294.tar.gz
ChangeLogTag:Wed Jul 25 16:29:48 2001 Steve Huston <shuston@riverace.com>
-rw-r--r--ChangeLog9
-rw-r--r--ChangeLogs/ChangeLog-02a9
-rw-r--r--ChangeLogs/ChangeLog-03a9
-rw-r--r--tests/Max_Default_Port_Test.cpp67
-rw-r--r--tests/Max_Default_Port_Test.h6
5 files changed, 74 insertions, 26 deletions
diff --git a/ChangeLog b/ChangeLog
index 28859ef2fc7..3eed27e086b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Wed Jul 25 16:29:48 2001 Steve Huston <shuston@riverace.com>
+
+ * tests/Max_Default_Port_Test.cpp: ACE-ified the code and fixed
+ a number of ACE_DEBUG %p directives without a corresponding
+ string. Also, closed a 2 handle-per-try handle leak, which
+ may have affected test results on some platforms.
+ * tests/Max_Default_Port_Test.h: Added a destructor to the
+ test class - it's used to close the acceptor handle down.
+
Wed Jul 25 15:21:22 2001 Krishnakumar B <kitty@cs.wustl.edu>
* ace/OS.h:
diff --git a/ChangeLogs/ChangeLog-02a b/ChangeLogs/ChangeLog-02a
index 28859ef2fc7..3eed27e086b 100644
--- a/ChangeLogs/ChangeLog-02a
+++ b/ChangeLogs/ChangeLog-02a
@@ -1,3 +1,12 @@
+Wed Jul 25 16:29:48 2001 Steve Huston <shuston@riverace.com>
+
+ * tests/Max_Default_Port_Test.cpp: ACE-ified the code and fixed
+ a number of ACE_DEBUG %p directives without a corresponding
+ string. Also, closed a 2 handle-per-try handle leak, which
+ may have affected test results on some platforms.
+ * tests/Max_Default_Port_Test.h: Added a destructor to the
+ test class - it's used to close the acceptor handle down.
+
Wed Jul 25 15:21:22 2001 Krishnakumar B <kitty@cs.wustl.edu>
* ace/OS.h:
diff --git a/ChangeLogs/ChangeLog-03a b/ChangeLogs/ChangeLog-03a
index 28859ef2fc7..3eed27e086b 100644
--- a/ChangeLogs/ChangeLog-03a
+++ b/ChangeLogs/ChangeLog-03a
@@ -1,3 +1,12 @@
+Wed Jul 25 16:29:48 2001 Steve Huston <shuston@riverace.com>
+
+ * tests/Max_Default_Port_Test.cpp: ACE-ified the code and fixed
+ a number of ACE_DEBUG %p directives without a corresponding
+ string. Also, closed a 2 handle-per-try handle leak, which
+ may have affected test results on some platforms.
+ * tests/Max_Default_Port_Test.h: Added a destructor to the
+ test class - it's used to close the acceptor handle down.
+
Wed Jul 25 15:21:22 2001 Krishnakumar B <kitty@cs.wustl.edu>
* ace/OS.h:
diff --git a/tests/Max_Default_Port_Test.cpp b/tests/Max_Default_Port_Test.cpp
index 5a979719166..b70b09b7c05 100644
--- a/tests/Max_Default_Port_Test.cpp
+++ b/tests/Max_Default_Port_Test.cpp
@@ -42,13 +42,21 @@ My_Accept_Handler::My_Accept_Handler (ACE_INET_Addr &addr)
this->open (addr);
}
+
+My_Accept_Handler::~My_Accept_Handler ()
+{
+ this->peer_acceptor_.close (); // Prevent handle leaks
+}
+
+
int
My_Accept_Handler::open (ACE_INET_Addr &addr)
{
- if (peer_acceptor_.open (addr, 1) == -1)
+ if (this->peer_acceptor_.open (addr, 1) == -1)
{
- ACE_ERROR ((LM_ERROR, "My_Accept_Handler open %p\n"));
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"),
+ ACE_TEXT ("My_Accept_Handler open")));
ACE_OS::exit (1);
}
@@ -59,22 +67,27 @@ My_Accept_Handler::open (ACE_INET_Addr &addr)
ACE_HANDLE
My_Accept_Handler::get_handle () const
{
- return peer_acceptor_.get_handle ();
+ return this->peer_acceptor_.get_handle ();
}
int
My_Accept_Handler::handle_input (ACE_HANDLE)
{
- if ( peer_acceptor_.accept(stream_, NULL) == -1) {
- ACE_ERROR((LM_ERROR, "peer_acceptor.accept %p\n"));
+ if (this->peer_acceptor_.accept(this->stream_, NULL) == -1) {
+ ACE_ERROR((LM_ERROR, ACE_TEXT ("%p\n"),
+ ACE_TEXT ("peer_acceptor.accept")));
ACE_OS::exit(1);
}
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("My_Accept_Handler::handle_input \n")));
- stream_.close ();
+ // Close the opened stream, else it'll leak a handle. Don't close
+ // the acceptor here, though, because get_handle() needs it to
+ // correctly allow removal from the reactor later. It gets closed
+ // in the destructor.
+ this->stream_.close ();
return 0;
}
@@ -121,9 +134,10 @@ client (void *arg)
int connected_port = server_addr.get_port_number ();
if (connected_port > max_connected_port)
-
max_connected_port = connected_port;
+ cli_stream.close ();
+
return 0;
}
@@ -150,11 +164,10 @@ main (int argc, ACE_TCHAR *argv[])
eh,
ACE_Event_Handler::ACCEPT_MASK) == -1)
{
- ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("Failed to register event handler %p\n")));
-
- ACE_OS::exit (1);
-
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("Failed to register event handler")),
+ 1);
}
ACE_DEBUG ((LM_DEBUG, "Registered event handler at %d\n", idx));
@@ -169,9 +182,10 @@ main (int argc, ACE_TCHAR *argv[])
ACE_reinterpret_cast (void *, &addr),
THR_NEW_LWP | THR_DETACHED) == -1)
- ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("(%P|%t) %p\n%a"),
- ACE_TEXT ("thread create failed")));
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) %p\n"),
+ ACE_TEXT ("thread create failed")),
+ 1);
ACE_Thread_Manager::instance ()->wait ();
@@ -184,8 +198,9 @@ main (int argc, ACE_TCHAR *argv[])
if (ACE_Reactor::instance()->handle_events (tv) == -1 )
{
- ACE_ERROR ((LM_ERROR, "Reactor::handle_events returned with error\n"));
- ACE_OS::exit (1);
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"),
+ ACE_TEXT ("Reactor::handle_events")),
+ 1);
}
// see if I can register a reactor at this port.
@@ -196,9 +211,10 @@ main (int argc, ACE_TCHAR *argv[])
}
else
{
- ACE_ERROR ((LM_ERROR, "Test Fail, listening port %d\n",
- eh->port()));
- ACE_OS::exit (1);
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Test Fail, listening port %d\n"),
+ eh->port()),
+ 1);
}
ACE_Reactor::instance()->remove_handler (
@@ -222,10 +238,17 @@ main (int argc, ACE_TCHAR *argv[])
if ((max_listened_port == ACE_MAX_DEFAULT_PORT) &&
(max_connected_port == ACE_MAX_DEFAULT_PORT))
- ACE_DEBUG ((LM_DEBUG, "Valid ACE_MAX_DEFAULT_PORT value \n"));
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Valid ACE_MAX_DEFAULT_PORT value: %d\n"),
+ max_listened_port));
+ }
else
{
- ACE_DEBUG ((LM_DEBUG, "Invalid ACE_MAX_DEFAULT_PORT or %d port may be busy\n", ACE_MAX_DEFAULT_PORT));
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Invalid ACE_MAX_DEFAULT_PORT ")
+ ACE_TEXT ("or %d port may be busy; got to %d\n"),
+ ACE_MAX_DEFAULT_PORT, max_listened_port));
}
diff --git a/tests/Max_Default_Port_Test.h b/tests/Max_Default_Port_Test.h
index c68b52542f3..c8304682b29 100644
--- a/tests/Max_Default_Port_Test.h
+++ b/tests/Max_Default_Port_Test.h
@@ -29,9 +29,9 @@ class My_Accept_Handler : public ACE_Event_Handler
// = Title
// A simple event handler
-
public:
My_Accept_Handler (ACE_INET_Addr &addr);
+ ~My_Accept_Handler ();
int open (ACE_INET_Addr &addr);
@@ -48,8 +48,6 @@ private:
ACE_SOCK_Stream stream_;
ACE_INET_Addr addr_;
-
-};
-
+};
#endif /* ACE_TESTS_MAX_DEFAULT_PORT_TEST */