fix missing mutex lock on eof