modify read and write of ring_buf.