blob: 641ed58256c8b54e2ce7bfde2ad1f6c990f4ac5b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
// $Id$
#include "Logging_Acceptor.h"
#include "Logging_Handler.h"
#include "Reactor_Singleton.h"
// Initialize peer_acceptor object.
int
Logging_Acceptor::open (const ACE_INET_Addr &addr)
{
// Reuse addr if already in use.
if (this->peer_acceptor_.open (addr, 1) == -1)
return -1;
else
return 0;
}
// Default constructor.
Logging_Acceptor::Logging_Acceptor (void)
{
}
// Performs termination activities.
int
Logging_Acceptor::handle_close (ACE_HANDLE, ACE_Reactor_Mask)
{
return this->peer_acceptor_.close ();
}
Logging_Acceptor::~Logging_Acceptor (void)
{
this->handle_close (ACE_INVALID_HANDLE,
ACE_Event_Handler::READ_MASK);
}
// Returns underlying device descriptor.
ACE_HANDLE
Logging_Acceptor::get_handle (void) const
{
return this->peer_acceptor_.get_handle ();
}
// Accepts connections from client and registers new object with the
// ACE_Reactor.
int
Logging_Acceptor::handle_input (ACE_HANDLE)
{
Logging_Handler *svc_handler = new Logging_Handler;
// Accept the connection from a client client daemon.
if (this->peer_acceptor_.accept (*svc_handler) == -1)
ACE_ERROR_RETURN ((LM_ERROR, "%p", "accept failed"), -1);
else if (svc_handler->open () == -1)
svc_handler->close ();
return 0;
}
|