I didn't dive enough into the code, but it would be a good idea to make this a rwmutex as well as a reader. That way you avoid race with gotEOF