Improved io error handling and thread yielding on buffer underrun