Skip to content

Commit 3d2dfa7

Browse files
committed
fix reset
1 parent 2dbf225 commit 3d2dfa7

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

include/ylt/coro_io/socket_wrapper.hpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
namespace coro_io {
2323
struct socket_wrapper_t {
2424
// construct by listen tcp
25-
socket_wrapper_t(){};
25+
socket_wrapper_t() {};
2626
socket_wrapper_t(coro_io::ExecutorWrapper<> *executor)
2727
: socket_(std::make_unique<asio::ip::tcp::socket>(
2828
executor->get_asio_executor())),
@@ -76,12 +76,6 @@ struct socket_wrapper_t {
7676
}
7777
#endif
7878

79-
void reset() {
80-
if (socket_) {
81-
*socket_ = asio::ip::tcp::socket(executor_->get_asio_executor());
82-
}
83-
}
84-
8579
private:
8680
std::unique_ptr<asio::ip::tcp::socket> socket_;
8781
coro_io::ExecutorWrapper<> *executor_;
@@ -171,8 +165,8 @@ struct socket_wrapper_t {
171165
ssl_stream_ = std::make_unique<asio::ssl::stream<asio::ip::tcp::socket &>>(
172166
*socket_, ssl_ctx);
173167
}
174-
std::unique_ptr<asio::ssl::stream<asio::ip::tcp::socket &>>
175-
&ssl_stream() noexcept {
168+
std::unique_ptr<asio::ssl::stream<asio::ip::tcp::socket &>> &
169+
ssl_stream() noexcept {
176170
return ssl_stream_;
177171
}
178172
using tcp_socket_with_ssl_t = asio::ssl::stream<asio::ip::tcp::socket &>;

include/ylt/coro_rpc/impl/coro_rpc_client.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,11 @@ class coro_rpc_client {
530530

531531
async_simple::coro::Lazy<void> reset() {
532532
co_await close_socket(control_);
533-
control_->socket_wrapper_.reset();
533+
std::visit(
534+
[this](auto &socket_config) {
535+
return init_socket_wrapper(socket_config);
536+
},
537+
config_.socket_config);
534538
control_->is_timeout_ = false;
535539
control_->has_closed_ = false;
536540
co_return;

0 commit comments

Comments
 (0)