diff options
author | Sage Weil <sage@newdream.net> | 2011-12-13 16:28:38 -0800 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2011-12-13 16:29:02 -0800 |
commit | 2f281d1ffdd533f7626c0250b65ea6a7a6e07c2c (patch) | |
tree | da7e6e97a75e93cc3136bff12a2be20d1d3e56ad /src/libcephfs.cc | |
parent | c87f31e0a5b9bdc8143a52021fca053266ef82bd (diff) | |
download | ceph-2f281d1ffdd533f7626c0250b65ea6a7a6e07c2c.tar.gz |
libceph: catch errors from Client::init()
And clean up error paths.
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'src/libcephfs.cc')
-rw-r--r-- | src/libcephfs.cc | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/src/libcephfs.cc b/src/libcephfs.cc index 974fe3a136a..41d4c93953a 100644 --- a/src/libcephfs.cc +++ b/src/libcephfs.cc @@ -63,6 +63,8 @@ public: int mount(const std::string &mount_root) { + int ret; + if (mounted) return -EDOM; @@ -70,42 +72,43 @@ public: //monmap monclient = new MonClient(cct); - if (monclient->build_initial_monmap() < 0) { - shutdown(); - return -1000; - } + ret = -1000; + if (monclient->build_initial_monmap() < 0) + goto fail; //network connection messenger = new SimpleMessenger(cct); if (!messenger->register_entity(entity_name_t::CLIENT())) { messenger->destroy(); messenger = NULL; - shutdown(); - return -1001; + ret = -1001; + goto fail; } //at last the client + ret = -1002; client = new Client(messenger, monclient); - if (!client) { - shutdown(); - return -1002; - } + if (!client) + goto fail; - if (messenger->start_with_nonce(msgr_nonce) != 0) { - shutdown(); - return -1003; - } + ret = -1003; + if (messenger->start_with_nonce(msgr_nonce) != 0) + goto fail; - client->init(); + ret = client->init(); + if (ret) + goto fail; - int ret = client->mount(mount_root); - if (ret) { - shutdown(); - return ret; - } + ret = client->mount(mount_root); + if (ret) + goto fail; mounted = true; return 0; + + fail: + shutdown(); + return ret; } void shutdown() |