libctf: fix spurious error when rolling back to the first snapshot
authorNick Alcock <nick.alcock@oracle.com>
Fri, 28 Jun 2019 21:11:14 +0000 (22:11 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Mon, 1 Jul 2019 10:05:59 +0000 (11:05 +0100)
The first ctf_snapshot called after CTF file creation yields a snapshot
handle that always yields a spurious ECTF_OVERROLLBACK error ("Attempt
to roll back past a ctf_update") on ctf_rollback(), even if ctf_update
has never been called.

The fix is to start with a ctf_snapshot value higher than the zero value
that ctf_snapshot_lu ("last update CTF snapshot value") is initialized
to.

libctf/
* ctf-create.c (ctf_create): Fix off-by-one error.

libctf/ChangeLog
libctf/ctf-create.c

index d07d5dc2e5f83f899b9b277cb4197d3bb5f2155c..1770f9922dde9c8c43785da336c6ffe9f025c48f 100644 (file)
@@ -1,3 +1,7 @@
+2019-06-28  Nick Alcock <nick.alcock@oracle.com>
+
+       * ctf-create.c (ctf_create): Fix off-by-one error.
+
 2019-06-28  Nick Alcock <nick.alcock@oracle.com>
 
        * ctf-impl.h: (struct ctf_strs_writable): New, non-const version of
index 6ab0cf3b88e429e61f48516e03206a885e1fabb9..24ea114f294426b08273adc43065dfff5d22702d 100644 (file)
@@ -82,7 +82,7 @@ ctf_create (int *errp)
   fp->ctf_dvhash = dvhash;
   fp->ctf_dtnextid = 1;
   fp->ctf_dtoldid = 0;
-  fp->ctf_snapshots = 0;
+  fp->ctf_snapshots = 1;
   fp->ctf_snapshot_lu = 0;
 
   return fp;