]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb2/test/lock-tracking.c
htable: fix bug where first entry has hash of 0 or 1.
[ccan] / ccan / tdb2 / test / lock-tracking.c
index 05dba32fd3fb9d0fa34999dd11dfc0453706c902..e253db9f710e6860ef2c4d7758daa5e010693a71 100644 (file)
@@ -1,10 +1,10 @@
 /* We save the locks so we can reaquire them. */
+#include <ccan/tdb2/tdb1_private.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <stdarg.h>
 #include <stdlib.h>
 #include <ccan/tap/tap.h>
-#include <ccan/tdb2/private.h>
 #include "lock-tracking.h"
 
 struct lock {
@@ -110,6 +110,17 @@ int fcntl_with_lockcheck(int fd, int cmd, ... /* arg */ )
                                        i->type = F_WRLCK;
                                goto done;
                        }
+                       /* allrecord upgrade for tdb1. */
+                       if (i->type == F_RDLCK && fl->l_type == F_WRLCK
+                           && i->off == TDB1_FREELIST_TOP
+                           && fl->l_start == TDB1_FREELIST_TOP
+                           && i->len == 0
+                           && fl->l_len == 0) {
+                               if (ret == 0)
+                                       i->type = F_WRLCK;
+                               goto done;
+                       }
+
                        if (!suppress_lockcheck) {
                                diag("%s lock %u@%u overlaps %u@%u",
                                     fl->l_type == F_WRLCK ? "write" : "read",