From 75140d6150264ba50a47e104c3ce1ae40bd3f0c8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 18 Mar 2006 10:38:38 +0000 Subject: r14540: fix a talloc hierachie problem, make sure file and search handles are cleaned up before anything else in the pvfs_state struct, as there destructors reply on a valid pvfs_state struct metze (This used to be commit aaa5d377b9b6145a83c0e686c7fbb7b561ae8988) --- source4/ntvfs/posix/vfs_posix.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'source4/ntvfs/posix/vfs_posix.c') diff --git a/source4/ntvfs/posix/vfs_posix.c b/source4/ntvfs/posix/vfs_posix.c index 3f1c676df3..cb441cb4c9 100644 --- a/source4/ntvfs/posix/vfs_posix.c +++ b/source4/ntvfs/posix/vfs_posix.c @@ -57,7 +57,7 @@ static void pvfs_setup_options(struct pvfs_state *pvfs) pvfs->alloc_size_rounding = lp_parm_int(snum, "posix", "allocationrounding", 512); - pvfs->search_inactivity_time = lp_parm_int(snum, + pvfs->search.inactivity_time = lp_parm_int(snum, "posix", "searchinactivity", 300); #if HAVE_XATTR_SUPPORT @@ -104,6 +104,28 @@ static void pvfs_setup_options(struct pvfs_state *pvfs) } } +static int pvfs_state_destructor(void *ptr) +{ + struct pvfs_state *pvfs = talloc_get_type(ptr, struct pvfs_state); + struct pvfs_file *f, *fn; + struct pvfs_search_state *s, *sn; + + /* + * make sure we cleanup files and searches before anythingelse + * because there destructors need to acess the pvfs_state struct + */ + for (f=pvfs->files.list; f; f=fn) { + fn = f->next; + talloc_free(f); + } + + for (s=pvfs->search.list; s; s=sn) { + sn = s->next; + talloc_free(s); + } + + return 0; +} /* connect to a share - used when a tree_connect operation comes @@ -169,18 +191,20 @@ static NTSTATUS pvfs_connect(struct ntvfs_module_context *ntvfs, } /* allocate the fnum id -> ptr tree */ - pvfs->idtree_fnum = idr_init(pvfs); - NT_STATUS_HAVE_NO_MEMORY(pvfs->idtree_fnum); + pvfs->files.idtree = idr_init(pvfs); + NT_STATUS_HAVE_NO_MEMORY(pvfs->files.idtree); /* allocate the search handle -> ptr tree */ - pvfs->idtree_search = idr_init(pvfs); - NT_STATUS_HAVE_NO_MEMORY(pvfs->idtree_search); + pvfs->search.idtree = idr_init(pvfs); + NT_STATUS_HAVE_NO_MEMORY(pvfs->search.idtree); status = pvfs_mangle_init(pvfs); NT_STATUS_NOT_OK_RETURN(status); pvfs_setup_options(pvfs); + talloc_set_destructor(pvfs, pvfs_state_destructor); + #ifdef SIGXFSZ /* who had the stupid idea to generate a signal on a large file write instead of just failing it!? */ -- cgit