From d19a49d3321c9edbca1a8842fa7c08daa3ed6f69 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Mon, 12 Jan 2015 08:55:35 -0800 Subject: [PATCH] cls_rgw: call ioctx->aio_operate() under lock close a race window Signed-off-by: Yehuda Sadeh --- src/cls/rgw/cls_rgw_client.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cls/rgw/cls_rgw_client.h b/src/cls/rgw/cls_rgw_client.h index 3341ad3ff76..c54b3330b50 100644 --- a/src/cls/rgw/cls_rgw_client.h +++ b/src/cls/rgw/cls_rgw_client.h @@ -61,7 +61,6 @@ private: * track the object id per callback. */ void add_pending(int id, librados::AioCompletion* completion, string *oid = NULL) { - Mutex::Locker l(lock); pendings[id] = completion; if (oid) { pending_objs[id] = *oid; @@ -96,6 +95,7 @@ public: * Do aio read operation. */ bool aio_operate(librados::IoCtx& io_ctx, const string& oid, librados::ObjectReadOperation *op) { + Mutex::Locker l(lock); BucketIndexAioArg *arg = new BucketIndexAioArg(get_next(), this); librados::AioCompletion *c = librados::Rados::aio_create_completion((void*)arg, NULL, bucket_index_op_completion_cb); int r = io_ctx.aio_operate(oid, c, (librados::ObjectReadOperation*)op, NULL); @@ -109,6 +109,7 @@ public: * Do aio write operation. */ bool aio_operate(librados::IoCtx& io_ctx, const string& oid, librados::ObjectWriteOperation *op) { + Mutex::Locker l(lock); BucketIndexAioArg *arg = new BucketIndexAioArg(get_next(), this); librados::AioCompletion *c = librados::Rados::aio_create_completion((void*)arg, NULL, bucket_index_op_completion_cb); int r = io_ctx.aio_operate(oid, c, (librados::ObjectWriteOperation*)op);