From 4ab8f717e23dda136f35c30ab103762afef6ff7a Mon Sep 17 00:00:00 2001 From: Shehjar Tikoo Date: Thu, 24 Sep 2009 00:57:40 +0000 Subject: booster: Cleanup booster_cleanup and register for atexit Signed-off-by: Anand V. Avati BUG: 279 (File written with booster results in self-heal after dd exits) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=279 --- booster/src/booster.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) (limited to 'booster') diff --git a/booster/src/booster.c b/booster/src/booster.c index bf2ad76d513..feb610729b8 100644 --- a/booster/src/booster.c +++ b/booster/src/booster.c @@ -1139,6 +1139,7 @@ fchown (int fd, uid_t owner, gid_t group) #define MOUNT_TABLE_HASH_SIZE 256 +static void booster_cleanup (void); static int booster_init (void) { @@ -1183,6 +1184,7 @@ booster_init (void) ret = booster_configure (DEFAULT_BOOSTER_CONF); } + atexit (booster_cleanup); if (ret == 0) gf_log ("booster", GF_LOG_DEBUG, "booster is inited"); return 0; @@ -1198,27 +1200,15 @@ err: static void booster_cleanup (void) { - /* gf_fd_fdtable_destroy (booster_fdtable);*/ - /*for (i=0; i < booster_fdtable->max_fds; i++) { - if (booster_fdtable->fds[i]) { - fd_t *fd = booster_fdtable->fds[i]; - free (fd); - } - }*/ - - free (booster_fdtable); - booster_fdtable = NULL; - - /* - * FIXME: there may be issues during execution of fini of individual - * xlators due to inconsistent lock states. - */ - - /* - * as above FIXME says, glusterfs_umount_all indeed leads to memory - * corruption, hence commenting out + /* Ideally, we should be de-initing the fd-table + * here but the problem is that I've seen file accesses through booster + * continuing while the atexit registered function is called. That means + * , we cannot dealloc the fd-table since then there could be a crash + * while trying to determine whether a given fd is for libc or for + * libglusterfsclient. + * We should be satisfied with having cleaned up glusterfs contexts. */ - /* glusterfs_umount_all (); */ + glusterfs_umount_all (); glusterfs_reset (); } -- cgit