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/smbd/conn.c | 9 ++++++--- source3/smbd/uid.c | 14 +++++++------- 2 files changed, 13 insertions(+), 10 deletions(-) (limited to 'source3/smbd') 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