From: lichaochao Date: Wed, 27 Sep 2023 10:06:34 +0000 (+0200) Subject: rgw: fix unwatch crash at radosgw startup X-Git-Tag: v17.2.7~34^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=74301a9af9c0dd4194bc634d3b48e2687bdb7e28;p=ceph.git rgw: fix unwatch crash at radosgw startup During radosgw initialization, if there is an exception in init_watch that causes the watcher registration to fail, When finalize_watch is executed, a crash occurs due to unregister an unregistered watch. Fixes: https://tracker.ceph.com/issues/60094 Signed-off-by: lichaochao (cherry picked from commit acd43489038495899c1fc4f1e719b19e8b842ca1) --- diff --git a/src/rgw/services/svc_notify.cc b/src/rgw/services/svc_notify.cc index 093e7d76534b..b97dd62d574c 100644 --- a/src/rgw/services/svc_notify.cc +++ b/src/rgw/services/svc_notify.cc @@ -247,7 +247,8 @@ void RGWSI_Notify::finalize_watch() { for (int i = 0; i < num_watchers; i++) { RGWWatcher *watcher = watchers[i]; - watcher->unregister_watch(); + if (watchers_set.find(i) != watchers_set.end()) + watcher->unregister_watch(); delete watcher; }