diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 2000-04-09 14:54:03 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 2000-04-09 14:54:03 +0000 |
commit | 3b78915d2effcdb7ae9d1a0d4f9bfc0c8c9063ae (patch) | |
tree | e2dd7523c5f05f405104195126828cf572d28e36 /ace/Acceptor.cpp | |
parent | 089ce38e44ce3b8c5f93d7b1622e1782cff5b4cb (diff) | |
download | ATCD-3b78915d2effcdb7ae9d1a0d4f9bfc0c8c9063ae.tar.gz |
hello
Diffstat (limited to 'ace/Acceptor.cpp')
-rw-r--r-- | ace/Acceptor.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/ace/Acceptor.cpp b/ace/Acceptor.cpp index 1860b5a500f..782d8246860 100644 --- a/ace/Acceptor.cpp +++ b/ace/Acceptor.cpp @@ -81,6 +81,14 @@ ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::open reuse_addr) == -1) return -1; + // Set the peer acceptor's handle into non-blocking mode. This is a + // safe-guard against the race condition that can otherwise occur + // between the time when <select> indicates that a passive-mode + // socket handle is "ready" and when we call <accept>. During this + // interval, the client can shutdown the connection, in which case, + // the <accept> call can hang! + this->peer_acceptor_.enable (ACE_NONBLOCK); + int result = reactor->register_handler (this, ACE_Event_Handler::ACCEPT_MASK); @@ -251,7 +259,7 @@ ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::make_svc_handler (SVC_HANDLER *& // Bridge method for accepting the new connection into the // <svc_handler>. The default behavior delegates to the -// PEER_ACCEPTOR::accept() in the Acceptor_Strategy. +// <PEER_ACCEPTOR::accept> in the Acceptor_Strategy. template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::accept_svc_handler @@ -266,12 +274,16 @@ ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::accept_svc_handler // associations. int reset_new_handle = this->reactor ()->uses_event_associations (); + // Note that it's not really an error if <accept> returns -1 and + // <errno> == EWOULDBLOCK because we have set the peer acceptor's + // handle into non-blocking mode to prevent the <accept> call from + // "hanging" if the connection has been shutdown. if (this->peer_acceptor_.accept (svc_handler->peer (), // stream 0, // remote address 0, // timeout 1, // restart reset_new_handle // reset new handler - ) == -1) + ) == -1 && errno != EWOULDBLOCK) { // Close down handler to avoid memory leaks. svc_handler->close (0); |