@@ -54,8 +54,11 @@ class RGWWatcher : public DoutPrefixProvider , public librados::WatchCtx2 {
5454 }
5555
5656public:
57- RGWWatcher (CephContext *_cct, RGWSI_Notify *s, int i, rgw_rados_ref& o)
58- : cct(_cct), svc(s), index(i), obj(o), watch_handle(0 ) {}
57+ RGWWatcher (CephContext *_cct, RGWSI_Notify *s, int i, rgw_rados_ref o)
58+ : cct(_cct), svc(s), index(i), obj(std::move(o)), watch_handle(0 ) {}
59+
60+ rgw_rados_ref& get_obj () { return obj; }
61+
5962 void handle_notify (uint64_t notify_id,
6063 uint64_t cookie,
6164 uint64_t notifier_id,
@@ -196,7 +199,7 @@ rgw_rados_ref RGWSI_Notify::pick_control_obj(const string& key)
196199 uint32_t r = ceph_str_hash_linux (key.c_str (), key.size ());
197200
198201 int i = r % num_watchers;
199- return notify_objs [i];
202+ return watchers [i]. get_obj () ;
200203}
201204
202205int RGWSI_Notify::init_watch (const DoutPrefixProvider *dpp, optional_yield y)
@@ -210,8 +213,6 @@ int RGWSI_Notify::init_watch(const DoutPrefixProvider *dpp, optional_yield y)
210213
211214 int error = 0 ;
212215
213- notify_objs.resize (num_watchers);
214-
215216 watchers.reserve (num_watchers);
216217
217218 for (int i=0 ; i < num_watchers; i++) {
@@ -223,13 +224,13 @@ int RGWSI_Notify::init_watch(const DoutPrefixProvider *dpp, optional_yield y)
223224 notify_oid = notify_oid_prefix;
224225 }
225226
227+ rgw_rados_ref notify_obj;
226228 int r = rgw_get_rados_ref (dpp, rados, { control_pool, notify_oid },
227- ¬ify_objs[i] );
229+ ¬ify_obj );
228230 if (r < 0 ) {
229231 ldpp_dout (dpp, 0 ) << " ERROR: notify_obj.open() returned r=" << r << dendl;
230232 return r;
231233 }
232- auto & notify_obj = notify_objs[i];
233234
234235 librados::ObjectWriteOperation op;
235236 op.create (false );
@@ -240,7 +241,7 @@ int RGWSI_Notify::init_watch(const DoutPrefixProvider *dpp, optional_yield y)
240241 return r;
241242 }
242243
243- auto & watcher = watchers.emplace_back (cct, this , i, notify_obj);
244+ auto & watcher = watchers.emplace_back (cct, this , i, std::move ( notify_obj) );
244245
245246 r = watcher.register_watch_async ();
246247 if (r < 0 ) {
0 commit comments