r22154: Make struct smbdb_ctx an opaque pointer so users of the API
[sfrench/samba-autobuild/.git] / source / include / locking.h
index 8eabb305f7f6e6c9a14666e3f3b97ac7762e7bbe..4b3b10d736768fc1c6971a50e1eac0239fe18823 100644 (file)
 #define _LOCKING_H
 
 /* passed to br lock code - the UNLOCK_LOCK should never be stored into the tdb
-   and is used in calculating POSIX unlock ranges only. */
+   and is used in calculating POSIX unlock ranges only. We differentiate between
+   PENDING read and write locks to allow posix lock downgrades to trigger a lock
+   re-evaluation. */
 
-enum brl_type {READ_LOCK, WRITE_LOCK, PENDING_LOCK, UNLOCK_LOCK};
+enum brl_type {READ_LOCK, WRITE_LOCK, PENDING_READ_LOCK, PENDING_WRITE_LOCK, UNLOCK_LOCK};
 enum brl_flavour {WINDOWS_LOCK = 0, POSIX_LOCK = 1};
 
+#define IS_PENDING_LOCK(type) ((type) == PENDING_READ_LOCK || (type) == PENDING_WRITE_LOCK)
+
 /* This contains elements that differentiate locks. The smbpid is a
    client supplied pid, and is essentially the locking context for
    this client */
@@ -51,6 +55,7 @@ struct byte_range_lock {
        struct files_struct *fsp;
        unsigned int num_locks;
        BOOL modified;
+       BOOL read_only;
        struct lock_key key;
        void *lock_data;
 };
@@ -67,12 +72,6 @@ struct byte_range_lock {
                                 enum brl_flavour lock_flav, \
                                 br_off start, br_off size)
 
-#define LOCKING_FN_CAST() \
-       void (*)(struct share_mode_entry *, const char *, const char *)
-
-#define LOCKING_FN(fn) \
-       void (*fn)(struct share_mode_entry *, const char *, const char *)
-
 /* Internal structure in brlock.tdb. 
    The data in brlock records is an unsorted linear array of these
    records.  It is unnecessary to store the count as tdb provides the