Commit 8344bd79 authored by Sebastien Ponce's avatar Sebastien Ponce
Browse files

Better cleanup of the ceph objects when disconnecting or failing to connect

parent e8de58de
......@@ -38,7 +38,7 @@ std::map<unsigned int, FileRef> g_fds;
/// global variable remembering the next available file descriptor
unsigned int g_nextCephFd = 0;
/// global variable for the log function. Defaults to one going to dev/null
/// global variable for the log function.
static void (*g_logfunc) (char *, va_list argp) = 0;
static void logwrapper(char* format, ...) {
......@@ -70,16 +70,32 @@ static libradosstriper::RadosStriper* getRadosStriper(std::string pool) {
}
librados::IoCtx ioctx;
rc = cluster.ioctx_create(pool.c_str(), ioctx);
if (rc != 0) return 0;
if (rc != 0) {
cluster.shutdown();
return 0;
}
libradosstriper::RadosStriper *newStriper = new libradosstriper::RadosStriper;
rc = libradosstriper::RadosStriper::striper_create(ioctx, newStriper);
if (rc != 0) return 0;
if (rc != 0) {
cluster.shutdown();
return 0;
}
it = g_radosStripers.insert(std::pair<std::string, libradosstriper::RadosStriper*>
(pool, newStriper)).first;
}
return it->second;
}
void ceph_posix_disconnect_all() {
for (std::map<std::string, libradosstriper::RadosStriper*>::iterator it =
g_radosStripers.begin();
it != g_radosStripers.end();
it++) {
delete it->second;
}
g_radosStripers.clear();
}
void ceph_open(CephFileRef &fr, const char *pathname, int flags, mode_t mode) {
std::string path = pathname;
int slashPos = path.find('/');
......@@ -223,7 +239,7 @@ int ceph_stat64(const char *pathname, struct stat64 *buf) {
}
int ceph_fcntl(CephFileRef &fr, int cmd) {
// minimal implementation for rfio
// minimal implementation
switch (cmd) {
case F_GETFL:
return fr.mode;
......
......@@ -16,6 +16,7 @@
extern "C" {
#endif
void ceph_posix_disconnect_all();
void ceph_posix_set_logfunc(void (*logfunc) (char *, va_list argp));
int ceph_posix_open(const char *pathname, int flags, mode_t mode);
int ceph_posix_close(int fd);
......
......@@ -163,7 +163,7 @@ static void ceph_logfunc_wrapper (char *format, va_list argp) {
* start
* -----
* This function is called when a new session is initialized, ie a user
* connectes to the server. This hook gives the dsi an oppertunity to
* connectes to the server. This hook gives the dsi an opportunity to
* set internal state that will be threaded through to all other
* function calls associated with this session. And an oppertunity to
* reject the user.
......@@ -211,7 +211,7 @@ static void globus_l_gfs_CASTOR2_start(globus_gfs_operation_t op,
* destroy
* -------
* This is called when a session ends, ie client quits or disconnects.
* The dsi should clean up all memory they associated wit the session
* The dsi should clean up all memory they associated with the session
* here.
************************************************************************/
static void globus_l_gfs_CASTOR2_destroy(void *user_arg) {
......@@ -1082,5 +1082,7 @@ static int globus_l_gfs_CASTOR2_activate(void) {
*/
static int globus_l_gfs_CASTOR2_deactivate(void) {
globus_extension_registry_remove(GLOBUS_GFS_DSI_REGISTRY, "CASTOR2");
// disconnect from ceph
ceph_posix_disconnect_all();
return 0;
}
......@@ -558,6 +558,8 @@ int main (int argc,
}
doit(0, &from, uid, gid);
}
// disconnect form ceph (if ever connected)
ceph_posix_disconnect_all();
exit(0);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment