mirror of
https://github.com/matrix-construct/construct
synced 2025-01-13 08:23:56 +01:00
ircd::net::socket: Switch to deadline timer.
This commit is contained in:
parent
c0fc0a1cad
commit
51e62a56f6
3 changed files with 10 additions and 4 deletions
|
@ -22,6 +22,7 @@
|
|||
namespace ircd::net
|
||||
{
|
||||
namespace ip = asio::ip;
|
||||
using asio::deadline_timer;
|
||||
using asio::steady_timer;
|
||||
using ircd::string;
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ struct ircd::net::socket
|
|||
ip::tcp::socket sd;
|
||||
asio::ssl::stream<ip::tcp::socket &> ssl;
|
||||
stat in, out;
|
||||
steady_timer timer;
|
||||
deadline_timer timer;
|
||||
uint64_t timer_sem[2] {0}; // handler, sender
|
||||
bool timer_set {false}; // boolean lockout
|
||||
bool timedout {false};
|
||||
|
|
11
ircd/net.cc
11
ircd/net.cc
|
@ -4109,9 +4109,9 @@ noexcept
|
|||
timer.expires_from_now()
|
||||
};
|
||||
|
||||
const auto ret
|
||||
const milliseconds ret
|
||||
{
|
||||
duration_cast<milliseconds>(exp)
|
||||
exp.total_milliseconds()
|
||||
};
|
||||
|
||||
timer_set = false;
|
||||
|
@ -4154,7 +4154,12 @@ ircd::net::socket::set_timeout(const milliseconds &t,
|
|||
assert(timedout == false);
|
||||
++timer_sem[1];
|
||||
timer_set = true;
|
||||
timer.expires_from_now(t);
|
||||
const boost::posix_time::milliseconds pt
|
||||
{
|
||||
t.count()
|
||||
};
|
||||
|
||||
timer.expires_from_now(pt);
|
||||
timer.async_wait(ios::handle(descriptor, std::move(handler)));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue