mirror of
https://github.com/matrix-construct/construct
synced 2024-11-26 00:32:35 +01:00
ircd::server: Add more state for async ops; adjust post points.
This commit is contained in:
parent
7f77c68232
commit
fc3b68b9e9
2 changed files with 18 additions and 4 deletions
|
@ -18,7 +18,9 @@ struct ircd::server::link
|
||||||
bool init {false}; ///< link is connecting
|
bool init {false}; ///< link is connecting
|
||||||
bool fini {false}; ///< link is disconnecting
|
bool fini {false}; ///< link is disconnecting
|
||||||
bool exclude {false}; ///< link is excluded
|
bool exclude {false}; ///< link is excluded
|
||||||
int8_t handles {0}; ///< async operations
|
bool waiting_write {false}; ///< async operation state
|
||||||
|
bool waiting_read {false}; ///< async operation state
|
||||||
|
int8_t handles {0}; ///< async operation state
|
||||||
std::shared_ptr<server::node> node; ///< backreference to node
|
std::shared_ptr<server::node> node; ///< backreference to node
|
||||||
std::shared_ptr<net::socket> socket; ///< link's socket
|
std::shared_ptr<net::socket> socket; ///< link's socket
|
||||||
std::list<tag> queue; ///< link's work queue
|
std::list<tag> queue; ///< link's work queue
|
||||||
|
|
|
@ -578,6 +578,8 @@ ircd::server::node::handle_link_done(link &link)
|
||||||
link.close();
|
link.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
link.wait_readable();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This is called when a tag on a link receives an HTTP response head.
|
/// This is called when a tag on a link receives an HTTP response head.
|
||||||
|
@ -990,6 +992,9 @@ ircd::server::link::handle_close(std::exception_ptr eptr)
|
||||||
void
|
void
|
||||||
ircd::server::link::wait_writable()
|
ircd::server::link::wait_writable()
|
||||||
{
|
{
|
||||||
|
if(waiting_write)
|
||||||
|
return;
|
||||||
|
|
||||||
auto handler
|
auto handler
|
||||||
{
|
{
|
||||||
std::bind(&link::handle_writable, this, ph::_1)
|
std::bind(&link::handle_writable, this, ph::_1)
|
||||||
|
@ -997,6 +1002,7 @@ ircd::server::link::wait_writable()
|
||||||
|
|
||||||
assert(ready());
|
assert(ready());
|
||||||
inc_handles();
|
inc_handles();
|
||||||
|
waiting_write = true;
|
||||||
net::wait(*socket, net::ready::WRITE, std::move(handler));
|
net::wait(*socket, net::ready::WRITE, std::move(handler));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1007,6 +1013,7 @@ try
|
||||||
using namespace boost::system::errc;
|
using namespace boost::system::errc;
|
||||||
using boost::system::system_category;
|
using boost::system::system_category;
|
||||||
|
|
||||||
|
waiting_write = false;
|
||||||
const unwind handled{[this]
|
const unwind handled{[this]
|
||||||
{
|
{
|
||||||
dec_handles();
|
dec_handles();
|
||||||
|
@ -1066,6 +1073,9 @@ ircd::server::link::handle_writable_success()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(tag_committed() == 0)
|
||||||
|
wait_readable();
|
||||||
|
|
||||||
if(!process_write(tag))
|
if(!process_write(tag))
|
||||||
{
|
{
|
||||||
wait_writable();
|
wait_writable();
|
||||||
|
@ -1090,9 +1100,6 @@ ircd::server::link::process_write(tag &tag)
|
||||||
tag_count(),
|
tag_count(),
|
||||||
tag.write_total());
|
tag.write_total());
|
||||||
|
|
||||||
if(tag_committed() == 0)
|
|
||||||
wait_readable();
|
|
||||||
|
|
||||||
while(tag.write_remaining())
|
while(tag.write_remaining())
|
||||||
{
|
{
|
||||||
const const_buffer buffer
|
const const_buffer buffer
|
||||||
|
@ -1134,6 +1141,9 @@ ircd::server::link::process_write_next(const const_buffer &buffer)
|
||||||
void
|
void
|
||||||
ircd::server::link::wait_readable()
|
ircd::server::link::wait_readable()
|
||||||
{
|
{
|
||||||
|
if(waiting_read)
|
||||||
|
return;
|
||||||
|
|
||||||
auto handler
|
auto handler
|
||||||
{
|
{
|
||||||
std::bind(&link::handle_readable, this, ph::_1)
|
std::bind(&link::handle_readable, this, ph::_1)
|
||||||
|
@ -1141,6 +1151,7 @@ ircd::server::link::wait_readable()
|
||||||
|
|
||||||
assert(ready());
|
assert(ready());
|
||||||
inc_handles();
|
inc_handles();
|
||||||
|
waiting_read = true;
|
||||||
net::wait(*socket, net::ready::READ, std::move(handler));
|
net::wait(*socket, net::ready::READ, std::move(handler));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1151,6 +1162,7 @@ try
|
||||||
using namespace boost::system::errc;
|
using namespace boost::system::errc;
|
||||||
using boost::system::system_category;
|
using boost::system::system_category;
|
||||||
|
|
||||||
|
waiting_read = false;
|
||||||
const unwind handled{[this]
|
const unwind handled{[this]
|
||||||
{
|
{
|
||||||
dec_handles();
|
dec_handles();
|
||||||
|
|
Loading…
Reference in a new issue