From f5fa5100de4b4b7f753b89c622cd9e2c82023037 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sat, 17 Mar 2018 23:19:33 -0700 Subject: [PATCH] ircd::net: Revert no-readahead; post immediate continuation to next stack. --- ircd/net.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/ircd/net.cc b/ircd/net.cc index a408aa1c7..3f021faac 100644 --- a/ircd/net.cc +++ b/ircd/net.cc @@ -1296,7 +1296,6 @@ ircd::net::socket::socket(asio::ssl::context &ssl, { ++count; ++instances; - SSL_set_read_ahead(this->ssl.native_handle(), false); } /// The dtor asserts that the socket is not open/connected requiring a @@ -1567,10 +1566,13 @@ ircd::net::socket::wait(const wait_opts &opts, // the wait. ASIO should fix this by adding a ssl::stream.wait() method // which will bail out immediately in this case before passing up to the // real socket wait. - assert(SSL_get_read_ahead(ssl.native_handle()) == 0); - if(SSL_peek(ssl.native_handle(), buf, sizeof(buf)) > 0) + if(SSL_peek(ssl.native_handle(), buf, sizeof(buf)) >= ssize_t(sizeof(buf))) { - handle(error_code{}, 1UL); //TODO: stack growth here + ircd::post([handle(std::move(handle))] + { + handle(error_code{}, 1UL); + }); + break; } @@ -1614,14 +1616,15 @@ noexcept try if(type == ready::READ && !ec && bytes == 0) ec = { asio::error::eof, asio::error::get_misc_category() }; - log.debug("socket(%p) local[%s] remote[%s] ready %s %s avail:%zu:%zu", + log.debug("socket(%p) local[%s] remote[%s] ready %s %s avail:%zu:%zu:%d", this, string(local_ipport(*this)), string(remote_ipport(*this)), reflect(type), string(ec), type == ready::READ? bytes : 0UL, - type == ready::READ? available(*this) : 0UL); + type == ready::READ? available(*this) : 0UL, + SSL_pending(ssl.native_handle())); call_user(callback, ec); }