summaryrefslogtreecommitdiff
path: root/source4/ntvfs/posix/pvfs_search.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-07-18 03:35:52 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:29:36 -0500
commitb37e82567d28626d39ce02c392d09a815cce497f (patch)
treee374845dfa17396ecd889dd250d56854fbb7d228 /source4/ntvfs/posix/pvfs_search.c
parent2ec501883d4c7d5d18cb1b457d94169960824817 (diff)
downloadsamba-b37e82567d28626d39ce02c392d09a815cce497f.tar.gz
samba-b37e82567d28626d39ce02c392d09a815cce497f.tar.bz2
samba-b37e82567d28626d39ce02c392d09a815cce497f.zip
r8535: no longer rely on seekdir working after a closedir. Instead, keep
directories open, but close search states based on an inactivity timer, with a default of a 5 minute timeout (This used to be commit 2e8d154e7dfb9b320a1344e957a39e96e1eefadd)
Diffstat (limited to 'source4/ntvfs/posix/pvfs_search.c')
-rw-r--r--source4/ntvfs/posix/pvfs_search.c39
1 files changed, 28 insertions, 11 deletions
diff --git a/source4/ntvfs/posix/pvfs_search.c b/source4/ntvfs/posix/pvfs_search.c
index 69ca6ef997..db197c7b62 100644
--- a/source4/ntvfs/posix/pvfs_search.c
+++ b/source4/ntvfs/posix/pvfs_search.c
@@ -24,6 +24,8 @@
#include "vfs_posix.h"
#include "system/time.h"
#include "librpc/gen_ndr/ndr_security.h"
+#include "smbd/service_stream.h"
+#include "lib/events/events.h"
/* the state of a search started with pvfs_search_first() */
@@ -37,6 +39,7 @@ struct pvfs_search_state {
time_t last_used;
uint_t num_ea_names;
struct ea_name *ea_names;
+ struct timed_event *te;
};
@@ -55,6 +58,28 @@ static int pvfs_search_destructor(void *ptr)
}
/*
+ called when a search timer goes off
+*/
+static void pvfs_search_timer(struct event_context *ev, struct timed_event *te,
+ struct timeval t, void *ptr)
+{
+ struct pvfs_search_state *search = talloc_get_type(ptr, struct pvfs_search_state);
+ talloc_free(search);
+}
+
+/*
+ setup a timer to destroy a open search after a inactivity period
+*/
+static void pvfs_search_setup_timer(struct pvfs_search_state *search)
+{
+ struct event_context *ev = search->pvfs->tcon->smb_conn->connection->event.ctx;
+ talloc_free(search->te);
+ search->te = event_add_timed(ev, search,
+ timeval_current_ofs(search->pvfs->search_inactivity_time, 0),
+ pvfs_search_timer, search);
+}
+
+/*
fill in a single search result for a given info level
*/
static NTSTATUS fill_search_info(struct pvfs_state *pvfs,
@@ -266,7 +291,7 @@ static NTSTATUS pvfs_search_fill(struct pvfs_state *pvfs, TALLOC_CTX *mem_ctx,
talloc_free(file);
}
- pvfs_list_hibernate(dir);
+ pvfs_search_setup_timer(search);
return NT_STATUS_OK;
}
@@ -362,6 +387,7 @@ static NTSTATUS pvfs_search_first_old(struct ntvfs_module_context *ntvfs,
search->search_attrib = search_attrib & 0xFF;
search->must_attrib = (search_attrib>>8) & 0xFF;
search->last_used = time(NULL);
+ search->te = NULL;
talloc_set_destructor(search, pvfs_search_destructor);
@@ -409,11 +435,6 @@ static NTSTATUS pvfs_search_next_old(struct ntvfs_module_context *ntvfs,
search->last_used = time(NULL);
dir = search->dir;
- status = pvfs_list_wakeup(dir, &search->current_index);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
-
status = pvfs_search_fill(pvfs, req, max_count, search, io->generic.level,
&reply_count, search_private, callback);
if (!NT_STATUS_IS_OK(status)) {
@@ -499,6 +520,7 @@ NTSTATUS pvfs_search_first(struct ntvfs_module_context *ntvfs,
search->last_used = 0;
search->num_ea_names = io->t2ffirst.in.num_names;
search->ea_names = io->t2ffirst.in.ea_names;
+ search->te = NULL;
talloc_set_destructor(search, pvfs_search_destructor);
@@ -573,11 +595,6 @@ NTSTATUS pvfs_search_next(struct ntvfs_module_context *ntvfs,
search->current_index = io->t2fnext.in.resume_key;
}
- status = pvfs_list_wakeup(dir, &search->current_index);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
-
search->num_ea_names = io->t2fnext.in.num_names;
search->ea_names = io->t2fnext.in.ea_names;