From 4da3933c12416d6083309d950525b7215ad9ea64 Mon Sep 17 00:00:00 2001 From: John Anthony Date: Fri, 21 Feb 2020 13:39:55 -0700 Subject: replacing use of select for poll Replacing use of ::select() with ::poll() in SSL_SOCK_Connector and SSL_SOCK_Acceptor - on systems that support ::poll() --- ACE/ace/SSL/SSL_SOCK_Acceptor.cpp | 50 +++++++++++++++++++++++++++++++++++--- ACE/ace/SSL/SSL_SOCK_Connector.cpp | 35 ++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 4 deletions(-) diff --git a/ACE/ace/SSL/SSL_SOCK_Acceptor.cpp b/ACE/ace/SSL/SSL_SOCK_Acceptor.cpp index d790662af29..d42eb01fbe6 100644 --- a/ACE/ace/SSL/SSL_SOCK_Acceptor.cpp +++ b/ACE/ace/SSL/SSL_SOCK_Acceptor.cpp @@ -10,6 +10,11 @@ #include "ace/Countdown_Time.h" #include "ace/Truncate.h" + +#if defined (ACE_HAS_POLL) +# include "ace/OS_NS_poll.h" +#endif /* ACE_HAS_POLL */ + #if !defined (__ACE_INLINE__) #include "SSL_SOCK_Acceptor.inl" #endif /* __ACE_INLINE__ */ @@ -65,10 +70,16 @@ ACE_SSL_SOCK_Acceptor::ssl_accept (ACE_SSL_SOCK_Stream &new_stream, int status; do { +#if defined (ACE_HAS_POLL) + struct pollfd fds; + ACE_OS::memset(&fds, 0, sizeof(fds)); + fds.revents = 0; +#else // These handle sets are used to set up for whatever SSL_accept // says it wants next. They're reset on each pass around the loop. ACE_Handle_Set rd_handle; ACE_Handle_Set wr_handle; +#endif /* ACE_HAS_POLL */ status = ::SSL_accept (ssl); switch (::SSL_get_error (ssl, status)) @@ -78,12 +89,22 @@ ACE_SSL_SOCK_Acceptor::ssl_accept (ACE_SSL_SOCK_Stream &new_stream, break; // Done case SSL_ERROR_WANT_WRITE: +#if defined (ACE_HAS_POLL) + fds.fd = handle; + fds.events = POLLOUT; +#else wr_handle.set_bit (handle); +#endif /* ACE_HAS_POLL */ status = 1; // Wait for more activity break; case SSL_ERROR_WANT_READ: +#if defined (ACE_HAS_POLL) + fds.fd = handle; + fds.events = POLLIN; +#else rd_handle.set_bit (handle); +#endif /* ACE_HAS_POLL */ status = 1; // Wait for more activity break; @@ -111,11 +132,27 @@ ACE_SSL_SOCK_Acceptor::ssl_accept (ACE_SSL_SOCK_Stream &new_stream, // Use that to decide what to do. status = 1; // Wait for more activity if (SSL_want_write (ssl)) - wr_handle.set_bit (handle); + { +#if defined (ACE_HAS_POLL) + fds.fd = handle; + fds.events = POLLOUT; +#else + wr_handle.set_bit (handle); +#endif /* ACE_HAS_POLL */ + } else if (SSL_want_read (ssl)) - rd_handle.set_bit (handle); - else - status = -1; // Doesn't want anything - bail out + { +#if defined (ACE_HAS_POLL) + fds.fd = handle; + fds.events = POLLIN; +#else + rd_handle.set_bit (handle); +#endif /* ACE_HAS_POLL */ + } + else + { + status = -1; // Doesn't want anything - bail out + } } else status = -1; @@ -129,6 +166,10 @@ ACE_SSL_SOCK_Acceptor::ssl_accept (ACE_SSL_SOCK_Stream &new_stream, if (status == 1) { +#if defined (ACE_HAS_POLL) + ACE_ASSERT(fds.fd != 0); + status = ACE_OS::poll(&fds, 1, timeout); +#else // Must have at least one handle to wait for at this point. ACE_ASSERT (rd_handle.num_set() == 1 || wr_handle.num_set () == 1); status = ACE::select (int (handle) + 1, @@ -136,6 +177,7 @@ ACE_SSL_SOCK_Acceptor::ssl_accept (ACE_SSL_SOCK_Stream &new_stream, &wr_handle, 0, timeout); +#endif /* ACE_HAS_POLL */ (void) countdown.update (); diff --git a/ACE/ace/SSL/SSL_SOCK_Connector.cpp b/ACE/ace/SSL/SSL_SOCK_Connector.cpp index 45df4ef0404..b6f4d2258b8 100644 --- a/ACE/ace/SSL/SSL_SOCK_Connector.cpp +++ b/ACE/ace/SSL/SSL_SOCK_Connector.cpp @@ -10,6 +10,10 @@ #include +#if defined (ACE_HAS_POLL) +# include "ace/OS_NS_poll.h" +#endif /* ACE_HAS_POLL */ + #if !defined (__ACE_INLINE__) #include "SSL_SOCK_Connector.inl" #endif /* __ACE_INLINE__ */ @@ -71,10 +75,16 @@ ACE_SSL_SOCK_Connector::ssl_connect (ACE_SSL_SOCK_Stream &new_stream, do { +#if defined (ACE_HAS_POLL) + struct pollfd fds; + ACE_OS::memset(&fds, 0, sizeof(fds)); + fds.revents = 0; +#else // These handle sets are used to set up for whatever SSL_connect // says it wants next. They're reset on each pass around the loop. ACE_Handle_Set rd_handle; ACE_Handle_Set wr_handle; +#endif /* ACE_HAS_POLL */ status = ::SSL_connect (ssl); switch (::SSL_get_error (ssl, status)) @@ -86,12 +96,22 @@ ACE_SSL_SOCK_Connector::ssl_connect (ACE_SSL_SOCK_Stream &new_stream, break; // Done case SSL_ERROR_WANT_WRITE: +#if defined (ACE_HAS_POLL) + fds.fd = handle; + fds.events = POLLOUT; +#else wr_handle.set_bit (handle); +#endif /* ACE_HAS_POLL */ status = 1; // Wait for more activity break; case SSL_ERROR_WANT_READ: +#if defined (ACE_HAS_POLL) + fds.fd = handle; + fds.events = POLLIN; +#else rd_handle.set_bit (handle); +#endif /* ACE_HAS_POLL */ status = 1; // Wait for more activity break; @@ -120,11 +140,21 @@ ACE_SSL_SOCK_Connector::ssl_connect (ACE_SSL_SOCK_Stream &new_stream, status = 1; // Wait for more activity if (SSL_want_write (ssl)) { +#if defined (ACE_HAS_POLL) + fds.fd = handle; + fds.events = POLLOUT; +#else wr_handle.set_bit (handle); +#endif /* ACE_HAS_POLL */ } else if (SSL_want_read (ssl)) { +#if defined (ACE_HAS_POLL) + fds.fd = handle; + fds.events = POLLIN; +#else rd_handle.set_bit (handle); +#endif /* ACE_HAS_POLL */ } else { @@ -146,6 +176,10 @@ ACE_SSL_SOCK_Connector::ssl_connect (ACE_SSL_SOCK_Stream &new_stream, if (status == 1) { +#if defined (ACE_HAS_POLL) + ACE_ASSERT(fds.fd != 0); + status = ACE_OS::poll(&fds, 1, timeout); +#else // Must have at least one handle to wait for at this point. ACE_ASSERT (rd_handle.num_set () == 1 || wr_handle.num_set () == 1); @@ -155,6 +189,7 @@ ACE_SSL_SOCK_Connector::ssl_connect (ACE_SSL_SOCK_Stream &new_stream, &wr_handle, 0, (timeout == 0 ? 0 : &t)); +#endif /* ACE_HAS_POLL */ (void) countdown.update (); -- cgit v1.2.1 From 26eb8172a683665ac3dd17d9f2eade14927dffb9 Mon Sep 17 00:00:00 2001 From: John Anthony Date: Tue, 24 Mar 2020 16:18:14 -0600 Subject: removing tabs --- ACE/ace/SSL/SSL_SOCK_Acceptor.cpp | 6 +++--- ACE/ace/SSL/SSL_SOCK_Connector.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ACE/ace/SSL/SSL_SOCK_Acceptor.cpp b/ACE/ace/SSL/SSL_SOCK_Acceptor.cpp index d42eb01fbe6..4e5e926e0f0 100644 --- a/ACE/ace/SSL/SSL_SOCK_Acceptor.cpp +++ b/ACE/ace/SSL/SSL_SOCK_Acceptor.cpp @@ -71,9 +71,9 @@ ACE_SSL_SOCK_Acceptor::ssl_accept (ACE_SSL_SOCK_Stream &new_stream, do { #if defined (ACE_HAS_POLL) - struct pollfd fds; - ACE_OS::memset(&fds, 0, sizeof(fds)); - fds.revents = 0; + struct pollfd fds; + ACE_OS::memset(&fds, 0, sizeof(fds)); + fds.revents = 0; #else // These handle sets are used to set up for whatever SSL_accept // says it wants next. They're reset on each pass around the loop. diff --git a/ACE/ace/SSL/SSL_SOCK_Connector.cpp b/ACE/ace/SSL/SSL_SOCK_Connector.cpp index b6f4d2258b8..21ac837ec4c 100644 --- a/ACE/ace/SSL/SSL_SOCK_Connector.cpp +++ b/ACE/ace/SSL/SSL_SOCK_Connector.cpp @@ -76,9 +76,9 @@ ACE_SSL_SOCK_Connector::ssl_connect (ACE_SSL_SOCK_Stream &new_stream, do { #if defined (ACE_HAS_POLL) - struct pollfd fds; - ACE_OS::memset(&fds, 0, sizeof(fds)); - fds.revents = 0; + struct pollfd fds; + ACE_OS::memset(&fds, 0, sizeof(fds)); + fds.revents = 0; #else // These handle sets are used to set up for whatever SSL_connect // says it wants next. They're reset on each pass around the loop. -- cgit v1.2.1 From 98ab6f28e5230f5561182c9914801d6d3a83b2bd Mon Sep 17 00:00:00 2001 From: John Anthony Date: Wed, 25 Mar 2020 11:06:24 -0600 Subject: removing trailing spaces --- ACE/ace/SSL/SSL_SOCK_Acceptor.cpp | 6 +++--- ACE/ace/SSL/SSL_SOCK_Connector.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ACE/ace/SSL/SSL_SOCK_Acceptor.cpp b/ACE/ace/SSL/SSL_SOCK_Acceptor.cpp index 4e5e926e0f0..0ed05b0052f 100644 --- a/ACE/ace/SSL/SSL_SOCK_Acceptor.cpp +++ b/ACE/ace/SSL/SSL_SOCK_Acceptor.cpp @@ -138,7 +138,7 @@ ACE_SSL_SOCK_Acceptor::ssl_accept (ACE_SSL_SOCK_Stream &new_stream, fds.events = POLLOUT; #else wr_handle.set_bit (handle); -#endif /* ACE_HAS_POLL */ +#endif /* ACE_HAS_POLL */ } else if (SSL_want_read (ssl)) { @@ -147,9 +147,9 @@ ACE_SSL_SOCK_Acceptor::ssl_accept (ACE_SSL_SOCK_Stream &new_stream, fds.events = POLLIN; #else rd_handle.set_bit (handle); -#endif /* ACE_HAS_POLL */ +#endif /* ACE_HAS_POLL */ } - else + else { status = -1; // Doesn't want anything - bail out } diff --git a/ACE/ace/SSL/SSL_SOCK_Connector.cpp b/ACE/ace/SSL/SSL_SOCK_Connector.cpp index 21ac837ec4c..d85fd545d27 100644 --- a/ACE/ace/SSL/SSL_SOCK_Connector.cpp +++ b/ACE/ace/SSL/SSL_SOCK_Connector.cpp @@ -145,7 +145,7 @@ ACE_SSL_SOCK_Connector::ssl_connect (ACE_SSL_SOCK_Stream &new_stream, fds.events = POLLOUT; #else wr_handle.set_bit (handle); -#endif /* ACE_HAS_POLL */ +#endif /* ACE_HAS_POLL */ } else if (SSL_want_read (ssl)) { @@ -154,7 +154,7 @@ ACE_SSL_SOCK_Connector::ssl_connect (ACE_SSL_SOCK_Stream &new_stream, fds.events = POLLIN; #else rd_handle.set_bit (handle); -#endif /* ACE_HAS_POLL */ +#endif /* ACE_HAS_POLL */ } else { -- cgit v1.2.1