@@ -85,9 +85,6 @@ Handler::TcpConnection::TcpConnection(
85
85
write_header_(handler_.pre_shared_key_.method().is_spec_2022()) {}
86
86
87
87
void Handler::TcpConnection::forward_read () {
88
- if (!stream_) {
89
- return ;
90
- }
91
88
BufferSpan read_buffer = decryptor_.buffer ();
92
89
stream_->async_read_some (
93
90
buffer (read_buffer.data (), read_buffer.size ()),
@@ -342,9 +339,6 @@ void Handler::TcpConnection::forward_parse_host(size_t header_length) {
342
339
}
343
340
344
341
void Handler::TcpConnection::forward_write () {
345
- if (!remote_stream_) {
346
- return ;
347
- }
348
342
async_write (
349
343
*remote_stream_,
350
344
buffer (decryptor_.pop_buffer (read_length_), read_length_),
@@ -361,9 +355,6 @@ void Handler::TcpConnection::forward_write() {
361
355
}
362
356
363
357
void Handler::TcpConnection::backward_read () {
364
- if (!remote_stream_) {
365
- return ;
366
- }
367
358
remote_stream_->async_read_some (
368
359
buffer (backward_read_buffer_.data (), backward_read_buffer_.size ()),
369
360
[connection = boost::intrusive_ptr<TcpConnection>(this )](
@@ -378,9 +369,6 @@ void Handler::TcpConnection::backward_read() {
378
369
}
379
370
380
371
void Handler::TcpConnection::backward_write () {
381
- if (!stream_) {
382
- return ;
383
- }
384
372
ConstBufferSpan read_buffer (
385
373
backward_read_buffer_.data (), backward_read_size_);
386
374
do {
@@ -420,8 +408,10 @@ void Handler::TcpConnection::backward_write() {
420
408
}
421
409
422
410
void Handler::TcpConnection::close () {
423
- remote_stream_.reset ();
424
- stream_.reset ();
411
+ if (remote_stream_) {
412
+ remote_stream_->close ();
413
+ }
414
+ stream_->close ();
425
415
}
426
416
427
417
} // namespace shadowsocks
0 commit comments