This creates a separate reference to an existing connection, for
use when a client holding IoCtx needs to consult another (say,
for rbd cloning)
Signed-off-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
static void version(int *major, int *minor, int *extra);
Rados();
+ explicit Rados(IoCtx& ioctx);
~Rados();
int init(const char * const id);
objecter(NULL),
lock("radosclient"),
timer(cct, lock),
+ refcnt(1),
finisher(cct),
max_watch_cookie(0)
{
return 0;
}
+void librados::RadosClient::get() {
+ Mutex::Locker l(lock);
+ assert(refcnt > 0);
+ refcnt++;
+}
+
+bool librados::RadosClient::put() {
+ Mutex::Locker l(lock);
+ assert(refcnt > 0);
+ refcnt--;
+ return (refcnt == 0);
+}
+
int librados::RadosClient::pool_create(string& name, unsigned long long auid,
__u8 crush_rule)
{
Mutex lock;
Cond cond;
SafeTimer timer;
+ int refcnt;
public:
Finisher finisher;
librados::WatchCtx *ctx, uint64_t *cookie);
void unregister_watcher(uint64_t cookie);
void watch_notify(MWatchNotify *m);
+ void get();
+ bool put();
};
#endif
{
}
+librados::Rados::Rados(IoCtx &ioctx)
+{
+ client = ioctx.io_ctx_impl->client;
+ assert(client != NULL);
+ client->get();
+}
+
librados::Rados::~Rados()
{
shutdown();
{
if (!client)
return;
- client->shutdown();
- delete client;
- client = NULL;
+ if (client->put()) {
+ client->shutdown();
+ delete client;
+ client = NULL;
+ }
}
uint64_t librados::Rados::get_instance_id()