Skip to content
This repository has been archived by the owner on Jun 21, 2019. It is now read-only.

high cpu usage in macOS #13

Open
SerhoLiu opened this issue Jun 4, 2018 · 0 comments
Open

high cpu usage in macOS #13

SerhoLiu opened this issue Jun 4, 2018 · 0 comments

Comments

@SerhoLiu
Copy link

SerhoLiu commented Jun 4, 2018

Hi, I use the latest version in macOS 10.13, tokio-socks5 cpu usage is very high。

some log:

Listening for socks5 proxy connections on 127.0.0.1:8080
error for 127.0.0.1:58096: timeout during handshake
error for 127.0.0.1:58100: Connection reset by peer (os error 54)
error for 127.0.0.1:58101: Connection reset by peer (os error 54)
proxied 568/168 bytes for 127.0.0.1:58099
proxied 568/168 bytes for 127.0.0.1:58120
error for 127.0.0.1:58122: Socket is not connected (os error 57)
error for 127.0.0.1:58108: Connection reset by peer (os error 54)
error for 127.0.0.1:58127: timeout during handshake
error for 127.0.0.1:58128: timeout during handshake
error for 127.0.0.1:58134: timeout during handshake

connection may RST by firewall . use dtruss trace:

sudo dtruss -p 9794

recvfrom(0xB, 0x10EC82980, 0x10000)      = -1 Err#35
recvfrom(0x1B, 0x10EC82980, 0x10000)     = -1 Err#35
recvfrom(0x1A, 0x10EC82980, 0x10000)     = -1 Err#35
recvfrom(0xA, 0x10EC82980, 0x10000)	= -1 Err#35
recvfrom(0xE, 0x10EC82980, 0x10000)       = -1 Err#35
...
...

add some log in: https://github.com/tokio-rs/tokio-socks5/blob/master/src/main.rs#L557

println!("poll.......");

and https://github.com/tokio-rs/tokio-core/blob/master/src/net/tcp.rs#L344

if let Async::Ready(x) = r {
    println!("poll read {:?}", x)
 }

log output:

poll.......
poll read Hup
poll.......
poll read Hup
poll.......
poll read Hup
poll.......
poll read Hup
poll.......
poll read Hup
poll.......
poll read Hup
poll.......
poll read Hup
...
...

It looks like HUP, poll read and poll write both Ready but read returns WouldBlock.

let read_ready = self.reader.poll_read().is_ready();
let write_ready = self.writer.poll_write().is_ready();
if !read_ready || !write_ready {
    return Ok(Async::NotReady)
}

let n = try_nb!((&*self.reader).read(&mut buffer));

some help?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant