io/uring/CancellableOperation: invoke OnUringCompletion() in destructor

This is important for operations that have complex cancellation
procedures (e.g. if they need to free buffers).  They might leave an
Operation instance in the queue.
This commit is contained in:
Max Kellermann 2025-02-04 10:10:06 +01:00 committed by Max Kellermann
parent e014d31972
commit 45644759fe

@ -10,6 +10,8 @@
#include <cassert>
#include <utility>
#include <errno.h> // for ECANCELED
namespace Uring {
class CancellableOperation
@ -26,7 +28,8 @@ public:
}
~CancellableOperation() noexcept {
assert(operation == nullptr);
if (operation != nullptr)
operation->OnUringCompletion(-ECANCELED);
}
void Cancel(Operation &_operation) noexcept {