diff options
Diffstat (limited to 'ace/SSL/SSL_Accept_Handler.cpp')
-rw-r--r-- | ace/SSL/SSL_Accept_Handler.cpp | 109 |
1 files changed, 0 insertions, 109 deletions
diff --git a/ace/SSL/SSL_Accept_Handler.cpp b/ace/SSL/SSL_Accept_Handler.cpp deleted file mode 100644 index 84073dabb23..00000000000 --- a/ace/SSL/SSL_Accept_Handler.cpp +++ /dev/null @@ -1,109 +0,0 @@ -// -*- C++ -*- - -#include "SSL_Accept_Handler.h" -#include "SSL_SOCK_Stream.h" - -#include <openssl/err.h> - -ACE_RCSID (ACE_SSL, - SSL_Accept_Handler, - "$Id$") - - -ACE_SSL_Accept_Handler::ACE_SSL_Accept_Handler (ACE_SSL_SOCK_Stream &s) - : ssl_stream_ (s) -{ -} - -ACE_SSL_Accept_Handler::~ACE_SSL_Accept_Handler (void) -{ -} - -ACE_HANDLE -ACE_SSL_Accept_Handler::get_handle (void) const -{ - return this->ssl_stream_.get_handle (); -} - -int -ACE_SSL_Accept_Handler::handle_input (ACE_HANDLE) -{ - return this->ssl_accept (); -} - -int -ACE_SSL_Accept_Handler::handle_output (ACE_HANDLE) -{ - return this->ssl_accept (); -} - -int -ACE_SSL_Accept_Handler::handle_close (ACE_HANDLE /* handle */, - ACE_Reactor_Mask /* close_mask */) -{ - return this->ssl_stream_.close (); -} - - -int -ACE_SSL_Accept_Handler::ssl_accept (void) -{ - SSL *ssl = this->ssl_stream_.ssl (); - - // A race condition exists where data may be sent over an SSL - // session after the SSL passive connection is completed but before - // this event handler is deregistered from the Reactor. - // Specifically data meant to be handled by SSL_read() could end up - // being handled by the SSL_accept() call below, resulting in an SSL - // protocol error (i.e. "SSL_ERROR_SSL" error status). The - // following check avoids the race condition. - if (SSL_is_init_finished (ssl)) - return 0; - - int status = ::SSL_accept (ssl); - - switch (::SSL_get_error (ssl, status)) - { - case SSL_ERROR_NONE: - break; - - case SSL_ERROR_WANT_WRITE: - case SSL_ERROR_WANT_READ: - // If data is still buffered within OpenSSL's internal buffer, - // then force the Reactor to invoke the SSL accept event handler - // (with the appropriate mask) before waiting for more events - // (e.g. blocking on select()). All pending data must be - // processed before waiting for more events to come in on the - // SSL handle. - if (::SSL_pending (ssl)) - return 1; - - break; - - case SSL_ERROR_ZERO_RETURN: - // The peer has notified us that it is shutting down via - // the SSL "close_notify" message so we need to - // shutdown, too. - // - // Removing this event handler causes the SSL stream to be - // shutdown. - return -1; - - case SSL_ERROR_SYSCALL: - // On some platforms (e.g. MS Windows) OpenSSL does not - // store the last error in errno so explicitly do so. - // - // Explicitly check for EWOULDBLOCK since it doesn't get - // converted to an SSL_ERROR_WANT_{READ,WRITE} on some - // platforms, such as AIX. - if (ACE_OS::set_errno_to_last_error () == EWOULDBLOCK) - return 0; - - default: - ACE_SSL_Context::report_error (); - - return -1; - } - - return 0; -} |