0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-08 21:18:57 +02:00

ircd::net::socket: Switch to deadline timer.

This commit is contained in:
Jason Volk 2019-10-08 18:14:10 -07:00
parent c0fc0a1cad
commit 51e62a56f6
3 changed files with 10 additions and 4 deletions

View file

@ -22,6 +22,7 @@
namespace ircd::net
{
namespace ip = asio::ip;
using asio::deadline_timer;
using asio::steady_timer;
using ircd::string;

View file

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

View file

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