fixed file descriptor leaks
fixed tls file descriptor leaks