Cache Multithreading Issue
Brought to you by:
ramr
Duplicate records end up in the cache due to multithreading issues. Here is the scenario:
Thread 1 checks for the user in cache.
Thread 1 does not find user, connects to LDAP and verifies password. Thread yields during this time.
Thread 2 checks for the user in cache.
Thread 2 does not find user, connects to LDAP and verifies password. Thread yields during this time.
Thread 1 adds the user. Exits
Thread 2 adds the user. Exits.
The problem is that Cache_AddUser() does not check the cache for the user. This is intentional for performance reasons.
The cache should be rewritten in a faster fashion so this issue is resolved by checking for the record before adding.