diff options
author | Volker Lendecke <vl@samba.org> | 2008-05-07 15:51:42 +0200 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2008-05-10 11:17:00 +0200 |
commit | c881c866d656bacb30180b574f3634db26deb37a (patch) | |
tree | 6040f06a863feab0042a24a1cd9638580d3329c5 | |
parent | 322896f8dd9e7d92fe677178bd131fcfc09319f2 (diff) | |
download | samba-c881c866d656bacb30180b574f3634db26deb37a.tar.gz samba-c881c866d656bacb30180b574f3634db26deb37a.tar.bz2 samba-c881c866d656bacb30180b574f3634db26deb37a.zip |
Next try at making the vuid cache circular
Jeremy, please check!
(This used to be commit a34f73521712e3820d417f0d9ed811723b7681d6)
-rw-r--r-- | source3/include/smb.h | 2 | ||||
-rw-r--r-- | source3/smbd/conn.c | 9 | ||||
-rw-r--r-- | 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;i<conn->vuid_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; i<VUID_CACHE_SIZE; i++) { + struct vuid_cache_entry *ent; + + ent = &conn->vuid_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;i<conn->vuid_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; i<VUID_CACHE_SIZE; i++) { + ent = &conn->vuid_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; |