Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Buffered transactions dont finish correctly
A Buffered transaction will hold any data written to it in an internal `Vec<u8>`. When it is `finish()`ed, it will write that buffer to the underlying writer. The `finish` and `poll_finish` implementations would write any such data but without remembering how much data they had written. This is not a problem for the synchronous `finish()` as that writes the buffer all in one go and as such does not need to remember how much data it wrote. However, in the asynchronous implementation, if the transaction happenned to also want a flush after writing the data and `poll_flush()` returned with `Poll::Pending`, then the entire `poll_finish()` would return with `Poll::Pending`. The next time the `Finish` future would be polled, the `poll_future()` will re-write the entire buffer back to the underlying writer because it wouldn't know if any of it had been written previously. This commit changes the internal buffer from a `&mut Vec<u8>` to a `Cursor<&mut Vec<u8>>` which holds a position in the buffer eliminating the bug.
- Loading branch information