opendnssec/SoftHSMv2 — pull request #20 by fxdupont (2013-10-23 13:39:08+00:00)
Title: Replace semaphore counters by generation counters

It is a heavy change based on:
- the fact the semaphore counter idea is broken:
* sem_getvalue() is not available on all systems (e.g., OS X)
* NetBSD has incompatible constraints on semaphore names
* IMHO there are systems where the maximum number of semaphores is too low (compared to the maximum number of objects we'd like to support)
* a semaphore counter behaves badly where it wraps

- the idea is a more standard generation number stored at the beginning of object files and for tokens in its own file

Tested on Linux and OS X (so OS X can be added into the supported system list and the corresponding ticket closed).

Not yet implemented:
- Directory lock (multi-thread bug was fixed by moving the thread lock at the beginning but it should be more efficient and logical to lock in the Directory routines)
- (ObjectFile) move refresh() to isValid() (performance point: ods-hsmspeed spent 1/4 in refresh()
- call isValid() on OSObject's (not only for the previous point: if another process removes an object newP11Object() crashes by referencing class attribute). The idea is to call isValid() just after getObject() when the object will be used (vs. deleted).

Other ideas:
- finish the deserialize methods (IMHO a generic deserialize() class method should be usable on any object)