pbuffer[0] = '\0';
if ((code = ubik_CheckAuth(rxcall))) {
- DBHOLD(dbase);
- goto failed;
+ return code;
}
/* next, we do a sanity check to see if the guy sending us the database is
otherHost = ubikGetPrimaryInterfaceAddr(rx_HostOf(tpeer));
if (offset && offset != otherHost) {
/* we *know* this is the wrong guy */
- code = USYNC;
- DBHOLD(dbase);
- goto failed;
+ char sync_hoststr[16];
+ ubik_print
+ ("Ubik: Refusing synchronization with server %s since it is not the sync-site (%s).\n",
+ afs_inet_ntoa_r(otherHost, hoststr),
+ afs_inet_ntoa_r(offset, sync_hoststr));
+ return USYNC;
}
DBHOLD(dbase);
("Ubik: Synchronize database with server %s failed (error = %d)\n",
afs_inet_ntoa_r(otherHost, hoststr), code);
} else {
+ uvote_set_dbVersion(*avers);
ubik_print("Ubik: Synchronize database completed\n");
}
DBRELE(dbase);
ubik_print("... %s\n", afs_inet_ntoa_r(ts->addr[i], hoststr));
UBIK_ADDR_UNLOCK;
+
+ /*
+ * The most likely cause of a DISK_UpdateInterfaceAddr RPC
+ * is because the server was restarted. Reset its state
+ * so that no DISK_Begin RPCs will be issued until the
+ * known database version is current.
+ */
+ UBIK_BEACON_LOCK;
+ ts->beaconSinceDown = 0;
+ ts->currentDB = 0;
+ urecovery_LostServer(ts);
+ UBIK_BEACON_UNLOCK;
return 0;
}
goto done;
}
- /* Set the label if its version matches the sync-site's */
- if (uvote_eq_dbVersion(*oldversionp)) {
+ /* Set the label if our version matches the sync-site's. Also set the label
+ * if our on-disk version matches the old version, and our view of the
+ * sync-site's version matches the new version. This suggests that
+ * ubik_dbVersion was updated while the sync-site was setting the new
+ * version, and it already told us via VOTE_Beacon. */
+ if (uvote_eq_dbVersion(*oldversionp)
+ || (uvote_eq_dbVersion(*newversionp)
+ && vcmp(ubik_dbase->version, *oldversionp) == 0)) {
UBIK_VERSION_LOCK;
code = (*ubik_dbase->setlabel) (ubik_dbase, 0, newversionp);
if (!code) {