tdb: Enhance lock tracking a bit
authorVolker Lendecke <vl@samba.org>
Thu, 14 Feb 2013 15:10:31 +0000 (16:10 +0100)
committerStefan Metzmacher <metze@samba.org>
Tue, 19 Feb 2013 14:46:45 +0000 (15:46 +0100)
lock-tracking.c mirrors the in-kernel fcntl structures to detect
unexpected use of fcntl calls. During my mutex work I changed our fcntl
use so that we unlock the allrecord_lock in two pieces: The range covering
the hash locks and the range covering the data area for the individual
traverse record locks. Splitting locks is not covered by lock-tracking.c.

This patch extends lock-tracking.c with this little piece. It's still
far from complete to track the full range of fcntl semantics. It is not
strictly needed right now, but it does not hurt either.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
lib/tdb/test/lock-tracking.c

index 90a07f8ef164453aaff8a87871c4dd77bfca3c9a..b2f092c0c4df795bcb000137d2c99769c2374db7 100644 (file)
@@ -65,6 +65,17 @@ int fcntl_with_lockcheck(int fd, int cmd, ... /* arg */ )
                                }
                                break;
                        }
+                       if (((*l)->off == fl->l_start)
+                           && ((*l)->len == 0)
+                           && (ret == 0)) {
+                               /*
+                                * Remove a piece from the start of the
+                                * allrecord_lock
+                                */
+                               old = *l;
+                               (*l)->off += fl->l_len;
+                               break;
+                       }
                }
                if (!old && !suppress_lockcheck) {
                        diag("Unknown unlock %u@%u - %i",