Fix race condition when updating output buffers