From 6ea50dabd68db9a3199e1d3c16b82ec8774ad897 Mon Sep 17 00:00:00 2001 From: Haomai Wang Date: Sun, 10 Jul 2016 00:15:55 +0800 Subject: [PATCH] msg/async/Event: ensure not refer to member variable which may destroyed If nonwait is false, another thread is waiting for complete. After calling f() this thread will notify for finishing and at this moment another thread will destroy this C_submit_event right now. So we may refer to nonwait when C_submit_event is disappeared. Fixes: http://tracker.ceph.com/issues/16714 Signed-off-by: Haomai Wang --- src/msg/async/Event.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/msg/async/Event.h b/src/msg/async/Event.h index 89bede958c80..a320489ceda2 100644 --- a/src/msg/async/Event.h +++ b/src/msg/async/Event.h @@ -183,8 +183,9 @@ class EventCenter { lock.lock(); cond.notify_all(); done = true; + bool del = nonwait; lock.unlock(); - if (nonwait) + if (del) delete this; } void wait() { -- 2.47.3