fix write_buf_sem lock