From 9c03750acdf8f7dd5901c0f2e0f7d7f8c14ff3d7 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Mon, 23 Feb 2015 19:45:03 -0500 Subject: [PATCH] osdc: watch error callback invoked on cancelled context The C_DoWatchError context did not verify whether or not the watch was cancelled prior to invoking the callback. This resulted in sporadic crashes when reconnect errors bubbled up to destroyed objects. Signed-off-by: Jason Dillaman --- src/osdc/Objecter.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/osdc/Objecter.cc b/src/osdc/Objecter.cc index d9e57ecd2dcc3..abcfafbe08ae8 100644 --- a/src/osdc/Objecter.cc +++ b/src/osdc/Objecter.cc @@ -491,7 +491,14 @@ struct C_DoWatchError : public Context { info->_queued_async(); } void finish(int r) { - info->watch_context->handle_error(info->get_cookie(), err); + objecter->rwlock.get_read(); + bool canceled = info->canceled; + objecter->rwlock.put_read(); + + if (!canceled) { + info->watch_context->handle_error(info->get_cookie(), err); + } + info->finished_async(); info->put(); objecter->_linger_callback_finish(); -- 2.39.5