summaryrefslogtreecommitdiff
path: root/examples/Logger
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>1997-03-22 19:12:24 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>1997-03-22 19:12:24 +0000
commite23366181cb87e4bbbb90c9fb15cf1ef41618f93 (patch)
tree8223fe34197cbcaf6cc056367109d59b91802b68 /examples/Logger
parent67058e37923cba59203be9b005a84082099ac0f0 (diff)
downloadATCD-e23366181cb87e4bbbb90c9fb15cf1ef41618f93.tar.gz
es
Diffstat (limited to 'examples/Logger')
-rw-r--r--examples/Logger/Acceptor-server/server_loggerd.cpp21
-rw-r--r--examples/Logger/simple-server/Logging_Acceptor.cpp5
-rw-r--r--examples/Logger/simple-server/Logging_Acceptor.h1
-rw-r--r--examples/Logger/simple-server/Logging_Handler.cpp30
-rw-r--r--examples/Logger/simple-server/server_loggerd.cpp13
5 files changed, 33 insertions, 37 deletions
diff --git a/examples/Logger/Acceptor-server/server_loggerd.cpp b/examples/Logger/Acceptor-server/server_loggerd.cpp
index 20b0bb3d0af..d54871311a3 100644
--- a/examples/Logger/Acceptor-server/server_loggerd.cpp
+++ b/examples/Logger/Acceptor-server/server_loggerd.cpp
@@ -85,12 +85,8 @@ public:
// = Initialization and termination methods.
Logging_Handler (void);
- virtual void destroy (void);
- // Ensure dynamic allocation.
-
// = Hooks for opening and closing handlers.
virtual int open (void *);
- virtual int close (u_long);
protected:
// = Demultiplexing hooks.
@@ -113,13 +109,6 @@ Logging_Handler::Logging_Handler (void)
{
}
-void
-Logging_Handler::destroy (void)
-{
- REACTOR::instance ()->cancel_timer (this);
- this->peer ().close ();
-}
-
int
Logging_Handler::handle_timeout (const ACE_Time_Value &,
const void *arg)
@@ -218,16 +207,6 @@ Logging_Handler::open (void *)
}
}
-// Perform termination activities when deregistered from the
-// ACE_Reactor.
-
-int
-Logging_Handler::close (u_long)
-{
- this->destroy ();
- return 0;
-}
-
int
main (int argc, char *argv[])
{
diff --git a/examples/Logger/simple-server/Logging_Acceptor.cpp b/examples/Logger/simple-server/Logging_Acceptor.cpp
index c971f3537e9..96ef694d4a3 100644
--- a/examples/Logger/simple-server/Logging_Acceptor.cpp
+++ b/examples/Logger/simple-server/Logging_Acceptor.cpp
@@ -1,4 +1,3 @@
-
// $Id$
#include "Logging_Acceptor.h"
@@ -51,7 +50,9 @@ Logging_Acceptor::get_handle (void) const
int
Logging_Acceptor::handle_input (ACE_HANDLE)
{
- Logging_Handler *svc_handler = new Logging_Handler;
+ Logging_Handler *svc_handler;
+
+ ACE_NEW_RETURN (svc_handler, Logging_Handler, -1);
// Accept the connection from a client client daemon.
diff --git a/examples/Logger/simple-server/Logging_Acceptor.h b/examples/Logger/simple-server/Logging_Acceptor.h
index b653774ddd0..bfc5bbb3d3e 100644
--- a/examples/Logger/simple-server/Logging_Acceptor.h
+++ b/examples/Logger/simple-server/Logging_Acceptor.h
@@ -1,7 +1,6 @@
/* -*- C++ -*- */
// $Id$
-
// ============================================================================
//
// = LIBRARY
diff --git a/examples/Logger/simple-server/Logging_Handler.cpp b/examples/Logger/simple-server/Logging_Handler.cpp
index 5ffc425c5c4..f6aec6db542 100644
--- a/examples/Logger/simple-server/Logging_Handler.cpp
+++ b/examples/Logger/simple-server/Logging_Handler.cpp
@@ -106,27 +106,39 @@ Logging_Handler::open (void)
return -1;
else
{
- ACE_OS::strncpy (this->host_name_, addr.get_host_name (), MAXHOSTNAMELEN + 1);
+ ACE_OS::strncpy (this->host_name_,
+ addr.get_host_name (),
+ MAXHOSTNAMELEN + 1);
if (REACTOR::instance ()->register_handler
(this, ACE_Event_Handler::READ_MASK) == -1)
- ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) can't register with reactor\n"), -1);
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%P|%t) can't register with reactor\n"),
+ -1);
else if (REACTOR::instance ()->schedule_timer
- (this, (const void *) this, ACE_Time_Value (2), ACE_Time_Value (2)) == -1)
- ACE_ERROR_RETURN ((LM_ERROR, "can'(%P|%t) t register with reactor\n"), -1);
+ (this, (const void *) this,
+ ACE_Time_Value (2),
+ ACE_Time_Value (2)) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "can'(%P|%t) t register with reactor\n"),
+ -1);
else
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) connected with %s\n", this->host_name_));
+ ACE_DEBUG ((LM_DEBUG,
+ "(%P|%t) connected with %s\n",
+ this->host_name_));
return 0;
}
}
-// Perform termination activities when deregistered from the ACE_Reactor.
+// Perform termination activities when deregistered from the
+// ACE_Reactor.
int
-Logging_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask)
+Logging_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask mask)
{
// Must be allocated dynamically!
- delete this;
+ if (mask == ACE_Event_Handler::READ_MASK)
+ delete this;
return 0;
}
@@ -136,5 +148,5 @@ int
Logging_Handler::close (void)
{
return this->handle_close (ACE_INVALID_HANDLE,
- ACE_Event_Handler::ALL_EVENTS_MASK);
+ ACE_Event_Handler::READ_MASK);
}
diff --git a/examples/Logger/simple-server/server_loggerd.cpp b/examples/Logger/simple-server/server_loggerd.cpp
index 5d355ca2cc9..481ed097366 100644
--- a/examples/Logger/simple-server/server_loggerd.cpp
+++ b/examples/Logger/simple-server/server_loggerd.cpp
@@ -48,17 +48,22 @@ main (int argc, char *argv[])
if (peer_acceptor.open (addr) == -1)
ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1);
else if (REACTOR::instance ()->register_handler
- (&peer_acceptor, ACE_Event_Handler::ACCEPT_MASK) == -1)
- ACE_ERROR_RETURN ((LM_ERROR, "registering service with ACE_Reactor\n"), -1);
+ (&peer_acceptor,
+ ACE_Event_Handler::ACCEPT_MASK) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "registering service with ACE_Reactor\n"),
+ -1);
// Run forever, performing logging service.
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) starting up server logging daemon\n"));
+ ACE_DEBUG ((LM_DEBUG,
+ "(%P|%t) starting up server logging daemon\n"));
while (!finished)
REACTOR::instance ()->handle_events ();
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) shutting down server logging daemon\n"));
+ ACE_DEBUG ((LM_DEBUG,
+ "(%P|%t) shutting down server logging daemon\n"));
return 0;
}