Prevent leakage of SerialIoHandler by canceling I/O
In r626961 and r643767 we removed the CancelRead() and CancelWrite() calls from ~SerialConnection() with the assumption that since the SerialPortPtr was being closed it would cancel I/O in the process of closing the OS-level file handle. The problem is that SerialIoHandler explicitly retains a self-reference when submitting a read or write operation and until those are completed (or canceled) the object won't be destroyed and the OS-level file handle closed. SerialConnection solved this problem by explicitly canceling the I/O in its destructor and this patch moves that logic to ~SerialPortImpl(). A better long-term fix is to remove the self-references and make SerialIoHandler uniquely owned by SerialPortImpl but that requires other refactoring work. Bug: 964683 Change-Id: Ie5e59696df23c48dc9e9224772c621db5438c1f6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1707028 Commit-Queue: Reilly Grant <reillyg@chromium.org> Reviewed-by:Ovidio de Jesús Ruiz-Henríquez <odejesush@chromium.org> Cr-Commit-Position: refs/heads/master@{#678396}
Showing
Please register or sign in to comment