From 38ea70cadfbfff29bcc1da315f9f67e846364be6 Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Mon, 21 Mar 2011 14:50:12 +0000 Subject: [PATCH] Detect situation where resource internal identifier differs. This means that both nodes have separately managed resources that don't have the same data. MFC after: 1 week --- sbin/hastd/secondary.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sbin/hastd/secondary.c b/sbin/hastd/secondary.c index e718b2cfd480..cf27789de610 100644 --- a/sbin/hastd/secondary.c +++ b/sbin/hastd/secondary.c @@ -259,6 +259,19 @@ init_remote(struct hast_resource *res, struct nv *nvin) memset(map, 0xff, mapsize); } nv_add_uint8(nvout, HAST_SYNCSRC_PRIMARY, "syncsrc"); + } else if (res->hr_resuid != resuid) { + char errmsg[256]; + + (void)snprintf(errmsg, sizeof(errmsg), + "Resource unique ID mismatch (primary=%ju, secondary=%ju).", + (uintmax_t)resuid, (uintmax_t)res->hr_resuid); + pjdlog_error("%s", errmsg); + nv_add_string(nvout, errmsg, "errmsg"); + if (hast_proto_send(res, res->hr_remotein, nvout, NULL, 0) < 0) { + pjdlog_exit(EX_TEMPFAIL, "Unable to send response to %s", + res->hr_remoteaddr); + } + exit(EX_CONFIG); } else if ( /* Is primary is out-of-date? */ (res->hr_secondary_localcnt > res->hr_primary_remotecnt &&