0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-12 04:51:08 +01: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 ircd::net
{ {
namespace ip = asio::ip; namespace ip = asio::ip;
using asio::deadline_timer;
using asio::steady_timer; using asio::steady_timer;
using ircd::string; using ircd::string;

View file

@ -57,7 +57,7 @@ struct ircd::net::socket
ip::tcp::socket sd; ip::tcp::socket sd;
asio::ssl::stream<ip::tcp::socket &> ssl; asio::ssl::stream<ip::tcp::socket &> ssl;
stat in, out; stat in, out;
steady_timer timer; deadline_timer timer;
uint64_t timer_sem[2] {0}; // handler, sender uint64_t timer_sem[2] {0}; // handler, sender
bool timer_set {false}; // boolean lockout bool timer_set {false}; // boolean lockout
bool timedout {false}; bool timedout {false};

View file

@ -4109,9 +4109,9 @@ noexcept
timer.expires_from_now() timer.expires_from_now()
}; };
const auto ret const milliseconds ret
{ {
duration_cast<milliseconds>(exp) exp.total_milliseconds()
}; };
timer_set = false; timer_set = false;
@ -4154,7 +4154,12 @@ ircd::net::socket::set_timeout(const milliseconds &t,
assert(timedout == false); assert(timedout == false);
++timer_sem[1]; ++timer_sem[1];
timer_set = true; 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))); timer.async_wait(ios::handle(descriptor, std::move(handler)));
} }