Add a new function uvote_HaveSyncAndVersion() that combines the
logic from uvote_GetSyncSite and uvote_eq_dbVersion, without
releasing the vote lock in between. Make use of it in
urecovery_AllBetter.
Change-Id: Ia44337da0f4335bd312cd686904f633ac19f1b63
Reviewed-on: http://gerrit.openafs.org/4526
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
* that the sync site is still the sync site, 'cause it won't talk
* to us until a timeout period has gone by. When we recover, we
* leave this clear until we get a new dbase */
- else if ((uvote_GetSyncSite() && uvote_eq_dbVersion(ubik_dbase->version))) { /* && order is important */
+ else if (uvote_HaveSyncAndVersion(ubik_dbase->version)) {
rcode = 1;
}
extern struct vote_data vote_globals;
extern void uvote_set_dbVersion(struct ubik_version);
extern int uvote_eq_dbVersion(struct ubik_version);
+extern int uvote_HaveSyncAndVersion(struct ubik_version);
/*\}*/
#endif /* UBIK_INTERNALS */
UBIK_VOTE_UNLOCK;
return ret;
}
+
+/*!
+ * \brief Check if there is a sync site and whether we have a given db version
+ *
+ * \return 1 if there is a valid sync site, and the given db version matches the sync site's
+ */
+
+int
+uvote_HaveSyncAndVersion(struct ubik_version version)
+{
+ afs_int32 now;
+ int code;
+
+ UBIK_VOTE_LOCK;
+ now = FT_ApproxTime();
+ if (!vote_globals.lastYesState || (SMALLTIME + vote_globals.lastYesClaim < now) ||
+ vote_globals.ubik_dbVersion.epoch != version.epoch ||
+ vote_globals.ubik_dbVersion.counter != version.counter)
+ code = 0;
+ else
+ code = 1;
+ UBIK_VOTE_UNLOCK;
+ return code;
+}