summaryrefslogtreecommitdiff
path: root/source4/ntvfs/posix/vfs_posix.c
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2006-03-18 10:38:38 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:58:41 -0500
commit75140d6150264ba50a47e104c3ce1ae40bd3f0c8 (patch)
tree1345a43aeaaa6847a765ab69cb484a4dd7403d10 /source4/ntvfs/posix/vfs_posix.c
parent9225c02aee19478fc4825c4b798a6757d140b5c0 (diff)
downloadsamba-75140d6150264ba50a47e104c3ce1ae40bd3f0c8.tar.gz
samba-75140d6150264ba50a47e104c3ce1ae40bd3f0c8.tar.bz2
samba-75140d6150264ba50a47e104c3ce1ae40bd3f0c8.zip
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)
Diffstat (limited to 'source4/ntvfs/posix/vfs_posix.c')
-rw-r--r--source4/ntvfs/posix/vfs_posix.c34
1 files changed, 29 insertions, 5 deletions
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!? */