On 3/19/22 17:28, Jinoh Kang wrote:
async_set_result() is the only way the async completion callback can be called. If the async were a request async and the I/O failed even before it was marked as pending, async_handoff() simply discards the async without either calling async_set_result() or directly invoking the completion callback. This leads to memory leak.
Fix this by calling the completion_callback on synchronous failure path if it was not already called, setting it to NULL afterwards.
Signed-off-by: Jinoh Kang jinoh.kang.kr@gmail.com
I'm going to nitpick this, because I think clarity is very important here.
The assumption that's currently made about completion callbacks is that they're only set if the async is actually queued, and that assumption holds for all of the places that currently use them.
That could be reasonably changed, I think (although I'm not sure it strictly needs to be—we could duplicate clearing events, I think either approach is reasonable) but it does mean that this description isn't really accurate.