Fix a concurrency bug, Fix a EOF bug