1 #include "ace/WFMO_Reactor.h"
2 #include "ace/Log_Msg.h"
4 #include "Logging_Acceptor.h"
5 #include "Logging_Handler.h"
6 #include "Reactor_Singleton.h"
8 // Initialize peer_acceptor object.
10 Logging_Acceptor::open (const ACE_INET_Addr
&addr
)
12 // Reuse addr if already in use.
13 if (this->peer_acceptor_
.open (addr
, 1) == -1)
19 // Performs termination activities.
21 Logging_Acceptor::handle_close (ACE_HANDLE
, ACE_Reactor_Mask
)
23 this->peer_acceptor_
.close ();
24 // Note, this object MUST be allocated dynamically!
29 // Returns underlying device descriptor.
31 Logging_Acceptor::get_handle () const
33 return this->peer_acceptor_
.get_handle ();
36 // Accepts connections from client and registers new object with the
39 Logging_Acceptor::handle_input (ACE_HANDLE
)
41 Logging_Handler
*svc_handler
;
43 ACE_NEW_RETURN (svc_handler
, Logging_Handler
, -1);
45 // Accept the connection from a client client daemon.
47 // Try to find out if the implementation of the reactor that we are
48 // using requires us to reset the event association for the newly
49 // created handle. This is because the newly created handle will
50 // inherit the properties of the listen handle, including its event
52 int const reset_new_handle
= this->reactor ()->uses_event_associations ();
54 if (this->peer_acceptor_
.accept (svc_handler
->peer (), // stream
58 reset_new_handle
// reset new handler
60 || svc_handler
->open () == -1)
62 svc_handler
->close ();
63 ACE_ERROR_RETURN ((LM_ERROR
, "%p", "accept/open failed"), -1);