Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Data frames release the underlying ByteBuf, not the wrapped Buf (link…
…erd#1751) The Finagle `ByteBufAsBuf` converter wraps a Netty 4 `ByteBuf`, but does not support reference counting (see [this comment](https://github.com/twitter/finagle/blob/82d00660373582d6bfe56df8155b52528df36691/finagle-netty4/src/main/scala/com/twitter/finagle/netty4/ByteBufAsBuf.scala#L58-L61)). Therefore, when releasing a data frame whose content `ByteBuf` we `retain()` before wrapping it as a `Buf`, we must `release()` the underlying `ByteBuf`. This fixes the memory leak observed in linkerd#1678 without removing the call to `retain()` which was removed in linkerd#1711, which introduced a data corruption issue (linkerd#1728). If we `release()` the underlying `ByteBuf` after releasing the data frame, we can once again `retain()` it before converting to `Buf` without leaking, thus avoiding the data corruption caused by removing the `retain()`. Thanks to @vadimi for helping with this fix! Fixes linkerd#1728.
- Loading branch information