From c881c866d656bacb30180b574f3634db26deb37a Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 7 May 2008 15:51:42 +0200 Subject: Next try at making the vuid cache circular Jeremy, please check! (This used to be commit a34f73521712e3820d417f0d9ed811723b7681d6) --- source3/include/smb.h | 2 +- source3/smbd/conn.c | 9 ++++++--- source3/smbd/uid.c | 14 +++++++------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/source3/include/smb.h b/source3/include/smb.h index c7a13fb3a0..dd8513f704 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -532,7 +532,7 @@ struct vuid_cache_entry { }; struct vuid_cache { - unsigned int entries; + unsigned int next_entry; struct vuid_cache_entry array[VUID_CACHE_SIZE]; }; diff --git a/source3/smbd/conn.c b/source3/smbd/conn.c index af18e905c0..3baf0cfaab 100644 --- a/source3/smbd/conn.c +++ b/source3/smbd/conn.c @@ -237,9 +237,12 @@ void conn_clear_vuid_cache(uint16 vuid) conn->vuid = UID_FIELD_INVALID; } - for (i=0;ivuid_cache.entries && i< VUID_CACHE_SIZE;i++) { - if (conn->vuid_cache.array[i].vuid == vuid) { - struct vuid_cache_entry *ent = &conn->vuid_cache.array[i]; + for (i=0; ivuid_cache.array[i]; + + if (ent->vuid == vuid) { ent->vuid = UID_FIELD_INVALID; ent->read_only = False; ent->admin_user = False; diff --git a/source3/smbd/uid.c b/source3/smbd/uid.c index 78dff8ffee..ce8aaa33ea 100644 --- a/source3/smbd/uid.c +++ b/source3/smbd/uid.c @@ -65,9 +65,9 @@ static bool check_user_ok(connection_struct *conn, user_struct *vuser,int snum) bool readonly_share; NT_USER_TOKEN *token; - for (i=0;ivuid_cache.entries && i< VUID_CACHE_SIZE;i++) { - if (conn->vuid_cache.array[i].vuid == vuser->vuid) { - ent = &conn->vuid_cache.array[i]; + for (i=0; ivuid_cache.array[i]; + if (ent->vuid == vuser->vuid) { conn->read_only = ent->read_only; conn->admin_user = ent->admin_user; return(True); @@ -102,11 +102,11 @@ static bool check_user_ok(connection_struct *conn, user_struct *vuser,int snum) return False; } - i = conn->vuid_cache.entries % VUID_CACHE_SIZE; - if (conn->vuid_cache.entries < VUID_CACHE_SIZE) - conn->vuid_cache.entries++; + ent = &conn->vuid_cache.array[conn->vuid_cache.next_entry]; + + conn->vuid_cache.next_entry = + (conn->vuid_cache.next_entry + 1) % VUID_CACHE_SIZE; - ent = &conn->vuid_cache.array[i]; ent->vuid = vuser->vuid; ent->read_only = readonly_share; -- cgit