2 #include "tao/Transport_Acceptor.h"
3 #include "ace/Reactor.h"
6 #if !defined (__ACE_INLINE__)
7 # include "tao/Transport_Acceptor.inl"
8 #endif /* __ACE_INLINE__ */
10 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
12 TAO_Acceptor::TAO_Acceptor (CORBA::ULong tag
)
14 error_retry_delay_ (5)
18 TAO_Acceptor::~TAO_Acceptor ()
23 TAO_Acceptor::handle_accept_error (ACE_Event_Handler
* base_acceptor
)
25 if (errno
== EMFILE
|| errno
== ENFILE
)
27 if (TAO_debug_level
> 0)
28 TAOLIB_DEBUG ((LM_DEBUG
, "TAO (%P|%t) - "
29 "TAO_Acceptor::handle_accept_error - "
30 "Too many files open\n"));
32 // If the user has decided to stop accepting when the file handles
33 // run out, just return -1;
34 if (this->error_retry_delay_
== 0)
37 // Get the reactor. If there isn't one, which isn't very likely,
38 // then just return -1.
39 ACE_Reactor
* reactor
= base_acceptor
->reactor ();
40 if (reactor
== nullptr)
43 // So that the reactor doesn't completely remove this handler from
44 // the reactor, register it with the except mask. It should be
45 // removed in the timer handler.
46 reactor
->register_handler (base_acceptor
,
47 ACE_Event_Handler::EXCEPT_MASK
);
49 // Remove the handler so that the reactor doesn't attempt to
50 // process this handle again (and tightly spin).
51 reactor
->remove_handler (base_acceptor
,
52 ACE_Event_Handler::ACCEPT_MASK
|
53 ACE_Event_Handler::DONT_CALL
);
55 // Schedule a timer so that we can resume the handler in hopes
56 // that some file handles have freed up.
57 ACE_Time_Value
timeout (this->error_retry_delay_
);
58 reactor
->schedule_timer (base_acceptor
, nullptr, timeout
);
61 // We want to keep accepting in all other situations.
66 TAO_Acceptor::handle_expiration (ACE_Event_Handler
* base_acceptor
)
68 // Get the reactor. If there isn't one, which isn't very likely, then
70 ACE_Reactor
* reactor
= base_acceptor
->reactor ();
71 if (reactor
== nullptr)
74 if (TAO_debug_level
> 0)
75 TAOLIB_DEBUG ((LM_DEBUG
, "TAO (%P|%t) - "
76 "TAO_Acceptor::handle_expiration - "
77 "Re-registering the acceptor\n"));
79 // Try again to allow incoming connections
80 reactor
->register_handler (base_acceptor
, ACE_Event_Handler::ACCEPT_MASK
);
82 // Remove the except mask that was added during the handling of the
83 // accept() error. That is the only reason that we're in this method
84 // in the first place.
85 reactor
->remove_handler (base_acceptor
, ACE_Event_Handler::EXCEPT_MASK
|
86 ACE_Event_Handler::DONT_CALL
);
90 TAO_END_VERSIONED_NAMESPACE_DECL