librados: fix C interface error handling in init code

This commit is contained in:
Yehuda Sadeh 2010-12-06 10:28:20 -08:00
parent 63fab458f6
commit 130b8b3fe8

View File

@ -81,7 +81,7 @@ public:
}
~RadosClient();
bool init();
int init();
void shutdown();
struct PoolCtx {
@ -334,23 +334,25 @@ public:
}
};
bool RadosClient::init()
int RadosClient::init()
{
// get monmap
if (monclient.build_initial_monmap() < 0)
return false;
int ret = monclient.build_initial_monmap();
if (ret < 0)
return ret;
assert_warn(messenger);
if (!messenger)
return -ENOMEM;
dout(1) << "starting msgr at " << messenger->get_ms_addr() << dendl;
messenger->register_entity(entity_name_t::CLIENT(-1));
assert_warn(messenger);
if (!messenger)
return false;
dout(1) << "starting objecter" << dendl;
objecter = new Objecter(messenger, &monclient, &osdmap, lock, timer);
if (!objecter)
return false;
return -ENOMEM;
objecter->set_balanced_budget();
monclient.set_messenger(messenger);
@ -362,13 +364,13 @@ bool RadosClient::init()
dout(1) << "setting wanted keys" << dendl;
monclient.set_want_keys(CEPH_ENTITY_TYPE_MON | CEPH_ENTITY_TYPE_OSD);
dout(1) << "iit" << dendl;
dout(1) << "calling monclient init" << dendl;
monclient.init();
int err = monclient.authenticate(g_conf.client_mount_timeout);
if (err) {
dout(0) << *g_conf.entity_name << " authentication error " << strerror(-err) << dendl;
return false;
return err;
}
messenger->set_myname(entity_name_t::CLIENT(monclient.get_global_id()));
@ -388,7 +390,7 @@ bool RadosClient::init()
dout(1) << "init done" << dendl;
return true;
return 0;
}
void RadosClient::shutdown()
@ -1842,10 +1844,16 @@ extern "C" int rados_initialize(int argc, const char **argv)
if (!rados_initialized) {
__rados_init(argc, argv);
radosp = new RadosClient;
radosp->init();
if (!radosp) {
ret = -ENOMEM;
goto done;
}
ret = radosp->init();
if (ret < 0)
goto done;
}
++rados_initialized;
done:
rados_init_mutex.Unlock();
return ret;
}