s3: Add a "lock_order" argument to db_open
[obnox/samba/samba-obnox.git] / source3 / lib / dbwrap / dbwrap_open.c
index 6b8be2de16c6ba9a0654eed5cfdd563ceb2d7bb9..23d299511b4e245e4c1a73acbb1a3e52a87a96dc 100644 (file)
@@ -62,11 +62,26 @@ bool db_is_local(const char *name)
 struct db_context *db_open(TALLOC_CTX *mem_ctx,
                           const char *name,
                           int hash_size, int tdb_flags,
-                          int open_flags, mode_t mode)
+                          int open_flags, mode_t mode,
+                          enum dbwrap_lock_order lock_order)
 {
        struct db_context *result = NULL;
 #ifdef CLUSTER_SUPPORT
-       const char *sockname = lp_ctdbd_socket();
+       const char *sockname;
+#endif
+
+       if ((lock_order != DBWRAP_LOCK_ORDER_1) &&
+           (lock_order != DBWRAP_LOCK_ORDER_2)) {
+               /*
+                * Only allow 2 levels. ctdb gives us 3, and we will
+                * have the watchers database soon.
+                */
+               errno = EINVAL;
+               return NULL;
+       }
+
+#ifdef CLUSTER_SUPPORT
+       sockname = lp_ctdbd_socket();
 
        if(!sockname || !*sockname) {
                sockname = CTDB_PATH;