Stuart Lynne has provided a number of changes to slapd to remove some race conditions and to support per cache entry reader/writer locks. This code is currently in a devel branch OPENLDAP_DEVEL_THREAD. Please review. I hope to merge this into -devel later this week.