ldout(cct, 0) << "ERROR: failed to create instance for service " << svc->type() << " conf=" << conf << " (r=" << r << ")" << dendl;
return r;
}
+ svc->svc_registry = shared_from_this();
instance_ref->svc = svc;
instance_ref->svc_id = ++max_registry_id;
dep_refs[dep_id] = dep_ref;
}
+ ldout(cct, 10) << "svc: load service: " << instance_ref->get_svc()->type() << dendl;
r = instance_ref->load(conf, dep_refs);
+ ldout(cct, 10) << "svc: done load service: " << instance_ref->get_svc()->type() << dendl;
if (r < 0) {
ldout(cct, 0) << "ERROR: service instance load return error: service=" << svc->type() << " r=" << r << dendl;
return r;
}
for (auto& instance_ref : new_instances) {
+ ldout(cct, 10) << "svc: init service: " << instance_ref->get_svc()->type() << dendl;
r = instance_ref->init();
+ ldout(cct, 10) << "svc: done init service: " << instance_ref->get_svc()->type() << dendl;
if (r < 0) {
ldout(cct, 0) << "ERROR: service instance init return error: service=" << instance_ref->get_svc()->type() << " r=" << r << dendl;
return r;
}
};
-class RGWServiceRegistry {
+class RGWServiceRegistry : public std::enable_shared_from_this<RGWServiceRegistry> {
CephContext *cct;
map<string, RGWServiceRef> services;
notify_objs[i] = rados_svc->handle(0).obj({control_pool, notify_oid});
auto& notify_obj = notify_objs[i];
+ int r = notify_obj.open();
+ if (r < 0) {
+ ldout(cct, 0) << "ERROR: notify_obj.open() returned r=" << r << dendl;
+ return r;
+ }
+
librados::ObjectWriteOperation op;
op.create(false);
- int r = notify_obj.operate(&op);
+ r = notify_obj.operate(&op);
if (r < 0 && r != -EEXIST) {
+ ldout(cct, 0) << "ERROR: notify_obj.operate() returned r=" << r << dendl;
return r;
}
watchers_set.insert(i);
if (watchers_set.size() == (size_t)num_watchers) {
ldout(cct, 2) << "all " << num_watchers << " watchers are set, enabling cache" << dendl;
- set_enabled(true);
+ _set_enabled(true);
}
}
if (orig_size == (size_t)num_watchers &&
watchers_set.size() < orig_size) { /* actually removed */
ldout(cct, 2) << "removed watcher, disabling cache" << dendl;
- set_enabled(false);
+ _set_enabled(false);
}
}
void RGWSI_Notify::set_enabled(bool status)
{
RWLock::RLocker l(watchers_lock);
+ _set_enabled(status);
+}
+
+void RGWSI_Notify::_set_enabled(bool status)
+{
if (cb) {
cb->set_enabled(status);
}
uint64_t cookie,
uint64_t notifier_id,
bufferlist& bl);
+ void _set_enabled(bool status);
void set_enabled(bool status);
int robust_notify(RGWSI_RADOS::Obj& notify_obj, bufferlist& bl);
return ret;
}
}
+ std::swap(handles, rados);
return 0;
}
return r;
}
+ ref.has_ioctx = true;
ref.ioctx.locator_set_key(ref.key);
return 0;
rgw_pool pool;
string oid;
string key;
+ bool has_ioctx{false};
librados::IoCtx ioctx;
+
+ rgw_rados_ref() {}
+ ~rgw_rados_ref() {}
+
+ rgw_rados_ref(const rgw_rados_ref& r) : pool(r.pool),
+ oid(r.oid),
+ key(r.key),
+ has_ioctx(r.has_ioctx) {
+ if (r.has_ioctx) {
+ ioctx = r.ioctx;
+ }
+ }
+
+ rgw_rados_ref(const rgw_rados_ref&& r) : pool(std::move(r.pool)),
+ oid(std::move(r.oid)),
+ key(std::move(r.key)),
+ has_ioctx(r.has_ioctx) {
+ if (r.has_ioctx) {
+ ioctx = r.ioctx;
+ }
+ }
+
+ rgw_rados_ref& operator=(rgw_rados_ref&& r) {
+ pool = std::move(r.pool);
+ oid = std::move(r.oid);
+ key = std::move(r.key);
+ has_ioctx = r.has_ioctx;
+ if (has_ioctx) {
+ ioctx = r.ioctx;
+ }
+ return *this;
+ }
+
+ rgw_rados_ref& operator=(rgw_rados_ref& r) {
+ pool = r.pool;
+ oid = r.oid;
+ key = r.key;
+ has_ioctx = r.has_ioctx;
+ if (has_ioctx) {
+ ioctx = r.ioctx;
+ }
+ return *this;
+ }
};
class RGWSI_RADOS : public RGWServiceInstance
RGWObjVersionTracker *objv_tracker{nullptr};
map<string, bufferlist> attrs;
ceph::real_time mtime;
- ceph::real_time *pmtime;
+ ceph::real_time *pmtime{nullptr};
bool exclusive{false};
WOp& set_attrs(map<string, bufferlist>&& _attrs) {