Skip to content

Commit 55fe9b2

Browse files
Copilotarkq
andcommitted
Replace deadline_timer with system_timer
Co-authored-by: arkq <6979798+arkq@users.noreply.github.com>
1 parent ebdf33a commit 55fe9b2

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

src/udp2tcp.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "udp2tcp.h"
66

77
#include <array>
8+
#include <chrono>
89
#include <functional>
910
#include <memory>
1011
#include <regex>
@@ -118,9 +119,9 @@ auto udp2tcp::do_app_keep_alive(bool init) -> void {
118119
if (m_app_keep_alive_idle_time == 0)
119120
return;
120121

121-
auto time = boost::posix_time::seconds(m_app_keep_alive_idle_time);
122+
auto time = std::chrono::seconds(m_app_keep_alive_idle_time);
122123
// Set or update timer and check whether the previous handler was cancelled
123-
if (m_app_keep_alive_timer.expires_from_now(time) == 0 && !init)
124+
if (m_app_keep_alive_timer.expires_after(time) == 0 && !init)
124125
return;
125126

126127
LOG(trace) << "app-keepalive [" << to_string() << "]: idle=" << m_app_keep_alive_idle_time;
@@ -216,8 +217,8 @@ auto udp2tcp::do_recv(std::size_t rlen, bool ctrl) -> void {
216217
[this, ctrl](const auto & ec, size_t length) { do_recv_handler(ec, length, ctrl); });
217218
}
218219

219-
auto udp2tcp::do_recv_handler(const boost::system::error_code & ec, size_t length, bool ctrl)
220-
-> void {
220+
auto udp2tcp::do_recv_handler(const boost::system::error_code & ec, size_t length,
221+
bool ctrl) -> void {
221222

222223
if (ec) {
223224
if (ec == asio::error::operation_aborted)

src/udp2tcp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class udp2tcp {
8282
utils::transport m_transport = utils::transport::raw;
8383
// Application keep-alive idle time in seconds, 0 to disable
8484
int m_app_keep_alive_idle_time = 0;
85-
asio::deadline_timer m_app_keep_alive_timer;
85+
asio::system_timer m_app_keep_alive_timer;
8686
// TCP keep-alive idle time in seconds, 0 to disable
8787
int m_tcp_keep_alive_idle_time = 0;
8888
// Buffers for sending and receiving data

0 commit comments

Comments
 (0)