diff options
author | Jeremy Allison <jra@samba.org> | 2002-04-04 03:03:39 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2002-04-04 03:03:39 +0000 |
commit | 464c1201978a2cd5abed8ea0d7bcb9486b1c92d8 (patch) | |
tree | eb67239c0c47ace3535d59cbf1dbd6c2a6494a10 /source3/nsswitch/winbindd_cache.c | |
parent | f21ccff91fe9dd37a57c6505fc19b7fc2c103a59 (diff) | |
download | samba-464c1201978a2cd5abed8ea0d7bcb9486b1c92d8.tar.gz samba-464c1201978a2cd5abed8ea0d7bcb9486b1c92d8.tar.bz2 samba-464c1201978a2cd5abed8ea0d7bcb9486b1c92d8.zip |
Fix up conversion code from old winbindd versions (some testing needed).
Added time based cache size check (#ifdef'ed out by default, just didn't
want to lose the code).
Jeremy.
(This used to be commit b2350ed36c42827c417ea4a3dd0668a4a631a090)
Diffstat (limited to 'source3/nsswitch/winbindd_cache.c')
-rw-r--r-- | source3/nsswitch/winbindd_cache.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/source3/nsswitch/winbindd_cache.c b/source3/nsswitch/winbindd_cache.c index 230d2b88b8..9bd95fdd86 100644 --- a/source3/nsswitch/winbindd_cache.c +++ b/source3/nsswitch/winbindd_cache.c @@ -34,6 +34,8 @@ struct cache_entry { uint32 len, ofs; }; +#define WINBINDD_MAX_CACHE_SIZE (50*1024*1024) + static struct winbind_cache *wcache; /* flush the cache */ @@ -56,6 +58,35 @@ void wcache_flush_cache(void) } } +void winbindd_check_cache_size(time_t t) +{ + static time_t last_check_time; + struct stat st; + + if (last_check_time == (time_t)0) + last_check_time = t; + + if (t - last_check_time < 60 && t - last_check_time > 0) + return; + + if (wcache == NULL || wcache->tdb == NULL) { + DEBUG(0, ("Unable to check size of tdb cache - cache not open !\n")); + return; + } + + if (fstat(wcache->tdb->fd, &st) == -1) { + DEBUG(0, ("Unable to check size of tdb cache %s!\n", strerror(errno) )); + return; + } + + if (st.st_size > WINBINDD_MAX_CACHE_SIZE) { + DEBUG(10,("flushing cache due to size (%lu) > (%lu)\n", + (unsigned long)st.st_size, + (unsigned long)WINBINDD_MAX_CACHE_SIZE)); + wcache_flush_cache(); + } +} + /* get the winbind_cache structure */ static struct winbind_cache *get_cache(struct winbindd_domain *domain) { |