Don't overload ri_csn with cookie, use a separate berval
Rewrote the psearch result handling to keep track of which
queues are using which results.
Remove assert. This is merely a cache of parent DNs, failure to
insert doesn't affect outcome.
Copied from 58ddb552.
Inconsistent reading & SIGSEGV due to the race condition.
Globally shared fields of meta-data were not 'volatile'.
Code from 9a80a8a8,
except the unportable __synchronize().