fix 100% cpu on close connection.
add timeout option.