diff options
author | luigi1111 <luigi1111w@gmail.com> | 2019-10-22 10:26:31 -0500 |
---|---|---|
committer | luigi1111 <luigi1111w@gmail.com> | 2019-10-22 10:26:31 -0500 |
commit | 6b58d6248a23cd09df385832f89d00af49acb853 (patch) | |
tree | 7f2a90de77249308620b4c26e3c27e448bcfebb2 /contrib/epee/src/net_ssl.cpp | |
parent | Merge pull request #5989 (diff) | |
parent | epee: fix SSL server handshake, run_one() can block, use poll_one() (diff) | |
download | monero-6b58d6248a23cd09df385832f89d00af49acb853.tar.xz |
Merge pull request #5996
23ba69e epee: fix SSL server handshake, run_one() can block, use poll_one() (xiphon)
Diffstat (limited to 'contrib/epee/src/net_ssl.cpp')
-rw-r--r-- | contrib/epee/src/net_ssl.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/contrib/epee/src/net_ssl.cpp b/contrib/epee/src/net_ssl.cpp index c7dca1914..16454fce0 100644 --- a/contrib/epee/src/net_ssl.cpp +++ b/contrib/epee/src/net_ssl.cpp @@ -27,6 +27,7 @@ // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <string.h> +#include <thread> #include <boost/asio/ssl.hpp> #include <boost/lambda/lambda.hpp> #include <openssl/ssl.h> @@ -519,10 +520,17 @@ bool ssl_options_t::handshake( boost::system::error_code ec = boost::asio::error::would_block; socket.async_handshake(type, boost::lambda::var(ec) = boost::lambda::_1); - while (ec == boost::asio::error::would_block) + if (io_service.stopped()) { io_service.reset(); - io_service.run_one(); + } + while (ec == boost::asio::error::would_block && !io_service.stopped()) + { + // should poll_one(), can't run_one() because it can block if there is + // another worker thread executing io_service's tasks + // TODO: once we get Boost 1.66+, replace with run_one_for/run_until + std::this_thread::sleep_for(std::chrono::milliseconds(30)); + io_service.poll_one(); } if (ec) |