Restructure opening and deleting the CNID dbs and CNID wraparound support
If opening the db fails, delete it and recreate a new empty one.
Add handling of CNID overflow, ie when the last used CNID reaches
its maximum (UINT32_MAX), wrap around to CNID_START. This then neccesites
a modification to get_id() where we used to just increment the last
used CNID counter and use that as next CNID.
Now we need to ensure that it isn't already used in the db and keep
searching for an used in case it is in a loop.
Move locking function back to main.c, as it's only used by cnid_dbd.
Modify dbd_add() such that it can add an entry with the CNID passed
in from the client, the CNID hint read from the adouble file.
Invalidate CNID hint in case lookup detected a problem