}
}
+ if ((aio_type == AIO_TYPE_CLOSE) ||
+ (aio_type == AIO_TYPE_OPEN && rval < 0)) {
+ // must destroy ImageCtx prior to invoking callback
+ delete ictx;
+ ictx = nullptr;
+ }
+
state = AIO_STATE_CALLBACK;
if (complete_cb) {
lock.Unlock();
lock.Lock();
}
- if (event_notify && ictx->event_socket.is_valid()) {
+ if (ictx != nullptr && event_notify && ictx->event_socket.is_valid()) {
ictx->completed_reqs_lock.Lock();
ictx->completed_reqs.push_back(&m_xlist_item);
ictx->completed_reqs_lock.Unlock();
Mutex::Locker locker(lock);
ceph_assert(ictx != nullptr);
ceph_assert(!async_op.started());
+
+ if (aio_type == AIO_TYPE_OPEN || aio_type == AIO_TYPE_CLOSE) {
+ // no need to track async open/close operations
+ return;
+ }
+
if (state == AIO_STATE_PENDING &&
(ignore_type || aio_type != AIO_TYPE_FLUSH)) {
async_op.start_op(*ictx);
int n = --ref;
lock.Unlock();
if (!n) {
- if (ictx) {
- if (event_notify) {
- ictx->completed_reqs_lock.Lock();
- m_xlist_item.remove_myself();
- ictx->completed_reqs_lock.Unlock();
- }
- if (aio_type == AIO_TYPE_CLOSE ||
- (aio_type == AIO_TYPE_OPEN && rval < 0)) {
- delete ictx;
- }
+ if (ictx != nullptr && event_notify) {
+ ictx->completed_reqs_lock.Lock();
+ m_xlist_item.remove_myself();
+ ictx->completed_reqs_lock.Unlock();
}
delete this;
}