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 <lichaochao2_yewu@cmss.chinamobile.com>
{
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;
}