Closed tjhuang closed 2 years ago
(by default 1024).
default where ?
would failed and re-try without any delay nor releasing allocated memory.
which memory is not released?
(by default 1024).
default where ? You can check the current system settings from:
$ ulimit -n
And in most system this value should be 1024.
would failed and re-try without any delay nor releasing allocated memory.
which memory is not released? In here: https://github.com/rofl0r/microsocks/blob/master/sockssrv.c#L439 The thread data allocated will not freed, and once "server_waitclient()" return failed, then go through the allocation again and again. In my testing result, this loop will consume more than 100 MB memory within 10 seconds.
merged as https://github.com/rofl0r/microsocks/commit/42143b138fc7fd8621dcfc8f2cc69276a1fe9bfe
(modified commit message to adhere to project standard and 80 char line length.)
Fix the resource exhausting issue. Every process has its maximum opened files limitation (by default 1024). When the microsocks received too many connection requests, then the line "server_waitclient()" would failed and re-try without any delay nor releasing allocated memory. In this fix, whenever failed to service client properly, wait for 1 ms before accepting new connection.
Here are steps to reproduce issue quickly: step 1: On server, execute "microsocks" step 2: On server, limit the maximum FD down to 5 via
prlimit --pid <microsocks pid> --nofile=5:5
step 3: On client, create connection to pass through socks server step 4: Monitor the system with "htop" on server, the CPU utilization going high and memory usage is rising.