From 9446b4536e247d67046c177a2728c8faeb8e0fa2 Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Mon, 21 Mar 2011 21:16:12 +0000 Subject: [PATCH] Initialize localcnt on first write. This fixes assertion when we create resource, set role to primary, do no writes, then sent it to secondary and accept connection from primary. MFC after: 1 week --- sbin/hastd/primary.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sbin/hastd/primary.c b/sbin/hastd/primary.c index 8beba488c80f..6b219f866610 100644 --- a/sbin/hastd/primary.c +++ b/sbin/hastd/primary.c @@ -478,7 +478,7 @@ init_local(struct hast_resource *res) * that there were no writes yet, so there is no need to synchronize * anything. */ - res->hr_primary_localcnt = 1; + res->hr_primary_localcnt = 0; res->hr_primary_remotecnt = 0; if (metadata_write(res) < 0) exit(EX_NOINPUT); @@ -1093,7 +1093,11 @@ ggate_recv_thread(void *arg) break; case BIO_WRITE: if (res->hr_resuid == 0) { - /* This is first write, initialize resuid. */ + /* + * This is first write, initialize localcnt and + * resuid. + */ + res->hr_primary_localcnt = 1; (void)init_resuid(res); } for (;;) {