tt->type = atype;
if (atype == UBIK_READTRANS)
adbase->readers++;
- else if (atype == UBIK_WRITETRANS)
+ else if (atype == UBIK_WRITETRANS) {
+ UBIK_VERSION_LOCK;
adbase->flags |= DBWRITING;
+ UBIK_VERSION_UNLOCK;
+ }
*atrans = tt;
return 0;
}
/* On the first write to the database. We update the versions */
if (ubeacon_AmSyncSite() && !(urecovery_state & UBIK_RECLABELDB)) {
+ UBIK_VERSION_LOCK;
oldversion = dbase->version;
newversion.epoch = FT_ApproxTime();;
newversion.counter = 1;
code = (*dbase->setlabel) (dbase, 0, &newversion);
if (code)
return (code);
- ubik_epochTime = newversion.epoch;
+ version_globals.ubik_epochTime = newversion.epoch;
dbase->version = newversion;
+ UBIK_VERSION_UNLOCK;
/* Ignore the error here. If the call fails, the site is
* marked down and when we detect it is up again, we will
urecovery_state |= UBIK_RECLABELDB;
}
+ UBIK_VERSION_LOCK;
dbase->version.counter++; /* bump commit count */
#ifdef AFS_PTHREAD_ENV
CV_BROADCAST(&dbase->version_cond);
dbase->version.counter--;
return (code);
}
+ UBIK_VERSION_UNLOCK;
/* If we fail anytime after this, then panic and let the
* recovery replay the log.
* we could be unsetting someone else's bit.
*/
if (atrans->type == UBIK_WRITETRANS && dbase->flags & DBWRITING) {
+ UBIK_VERSION_LOCK;
dbase->flags &= ~DBWRITING;
+ UBIK_VERSION_UNLOCK;
} else {
dbase->readers--;
}