0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 07:23:53 +01:00

ircd::net: Revert no-readahead; post immediate continuation to next stack.

This commit is contained in:
Jason Volk 2018-03-17 23:19:33 -07:00
parent 1780504cba
commit f5fa5100de

View file

@ -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);
}