修复循环buf的writetohead索引逻辑错误的bug