From: Mykola Golub Date: Tue, 13 Feb 2018 12:20:09 +0000 (+0200) Subject: librbd: potential race in RewatchRequest when resetting watch_handle X-Git-Tag: v12.2.9~14^2~9 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fb45b65171496e3d502cead877c9bc189a48aa5c;p=ceph.git librbd: potential race in RewatchRequest when resetting watch_handle Signed-off-by: Mykola Golub (cherry picked from commit f5c02adfdbf5d9da0186fd494ee33c469445be83) --- diff --git a/src/librbd/watcher/RewatchRequest.cc b/src/librbd/watcher/RewatchRequest.cc index e103732e00e7..fe236269793a 100644 --- a/src/librbd/watcher/RewatchRequest.cc +++ b/src/librbd/watcher/RewatchRequest.cc @@ -40,13 +40,14 @@ void RewatchRequest::unwatch() { CephContext *cct = reinterpret_cast(m_ioctx.cct()); ldout(cct, 10) << dendl; + uint64_t watch_handle = 0; + std::swap(*m_watch_handle, watch_handle); + librados::AioCompletion *aio_comp = create_rados_callback< RewatchRequest, &RewatchRequest::handle_unwatch>(this); - int r = m_ioctx.aio_unwatch(*m_watch_handle, aio_comp); + int r = m_ioctx.aio_unwatch(watch_handle, aio_comp); assert(r == 0); aio_comp->release(); - - *m_watch_handle = 0; } void RewatchRequest::handle_unwatch(int r) {