fengyouchao / sockslib

A Java library of SOCKS5 protocol including client and server
Apache License 2.0
284 stars 104 forks source link

Remove polling from the proxy server #18

Closed bemasc closed 4 years ago

bemasc commented 6 years ago

By default, the server currently polls every two seconds while waiting for an active connection to terminate, before freeing relevant resources. This is inefficient for idle and short-lived connections.

In this change, the polling is removed. Instead, the server thread sleeps until it is woken up by an event indicating that the connection has terminated or should be terminated.

This change also slightly alters the SocketPipe stop procedure, to ensure that all PipeListeners see a consistent view of the Pipe during onStop.