]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
WorkQueue: delay registering PointerWQ with thread pool
authorJason Dillaman <dillaman@redhat.com>
Wed, 13 Jan 2016 01:33:22 +0000 (20:33 -0500)
committerJason Dillaman <dillaman@redhat.com>
Wed, 13 Jan 2016 14:54:29 +0000 (09:54 -0500)
Derived classes should be responsible for registration to avoid
accessing a partially constructed object.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/common/WorkQueue.h
src/librbd/AioImageRequestWQ.cc

index a6e7972408f62a476649a35c2362373f4918b425..5103cdd0f0054d2bceaad958c12895fe0ad36d6a 100644 (file)
@@ -353,10 +353,6 @@ public:
   template<typename T>
   class PointerWQ : public WorkQueue_ {
   public:
-    PointerWQ(string n, time_t ti, time_t sti, ThreadPool* p)
-      : WorkQueue_(n, ti, sti), m_pool(p), m_processing(0) {
-      m_pool->add_work_queue(this);
-    }
     ~PointerWQ() {
       m_pool->remove_work_queue(this);
       assert(m_processing == 0);
@@ -382,6 +378,9 @@ public:
       return _empty();
     }
   protected:
+    PointerWQ(string n, time_t ti, time_t sti, ThreadPool* p)
+      : WorkQueue_(n, ti, sti), m_pool(p), m_processing(0) {
+    }
     virtual void _clear() {
       assert(m_pool->_lock.is_locked());
       m_items.clear();
@@ -579,6 +578,7 @@ public:
   ContextWQ(const string &name, time_t ti, ThreadPool *tp)
     : ThreadPool::PointerWQ<Context>(name, ti, 0, tp),
       m_lock("ContextWQ::m_lock") {
+    tp->add_work_queue(this);
   }
 
   void queue(Context *ctx, int result = 0) {
index 9871bb0535ef4c1b7f25531dc4f55a1ad5634bcf..f8efe0df6234b5dc69eeca767fd789b37ded074a 100644 (file)
@@ -27,6 +27,7 @@ AioImageRequestWQ::AioImageRequestWQ(ImageCtx *image_ctx, const string &name,
     m_shutdown(false), m_on_shutdown(nullptr) {
   CephContext *cct = m_image_ctx.cct;
   ldout(cct, 5) << this << " " << ": ictx=" << image_ctx << dendl;
+  tp->add_work_queue(this);
 }
 
 ssize_t AioImageRequestWQ::read(uint64_t off, uint64_t len, char *buf,