template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::accept_svc_handler (SVC_HANDLER *svc_handler) { ACE_TRACE ("ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::accept_svc_handler"); // Try to find out if the implementation of the reactor that we are // using requires us to reset the event association for the newly // created handle. This is because the newly created handle will // inherit the properties of the listen handle, including its event // associations. ACE_Reactor *reactor = this->reactor (); bool reset_new_handle; if (reactor) { reset_new_handle = reactor->uses_event_associations (); } else { // Acceptor is closed, so reject this call errno = EINVAL; return -1; } if (this->acceptor ().accept (svc_handler->peer (), // stream 0, // remote address 0, // timeout true, // restart reset_new_handle // reset new handler ) == -1) { // Ensure that errno is preserved in case the svc_handler // close() method resets it ACE_Errno_Guard error(errno); // Close down handler to avoid memory leaks. svc_handler->close (CLOSE_DURING_NEW_CONNECTION); return -1; } else return 0; }
template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_input (ACE_HANDLE) { ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_input"); int result = 0; // Cancel any timer that might be pending. this->cancel (); // Try to find out if the implementation of the reactor that we are // using requires us to reset the event association for the newly // created handle. This is because the newly created handle will // inherit the properties of the listen handle, including its event // associations. ACE_Reactor *reactor = this->reactor (); bool reset_new_handle = false; // There is a use-case whereby this object will be gone upon return // from shared_accept - if the Svc_Handler deletes this Oneshot_Acceptor // during the shared_accept/activation steps. So, do whatever we need // to do with this object before calling shared_accept. if (reactor) { reset_new_handle = reactor->uses_event_associations (); reactor->remove_handler (this, ACE_Event_Handler::ACCEPT_MASK | ACE_Event_Handler::DONT_CALL); } if (this->shared_accept (this->svc_handler_, // stream 0, // remote address 0, // timeout this->restart_, // restart reset_new_handle // reset new handle ) == -1) result = -1; return result; }