summaryrefslogtreecommitdiffstats
path: root/source3/include/g_lock.h
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-10-25 16:12:12 +0100
committerMichael Adam <obnox@samba.org>2010-02-12 23:12:09 +0100
commit4c1c3f2549f32fd069e0e7bf3aec299213f1e85b (patch)
treed7828ffb309c038c4ee1b1ddfc30d0ff6d99ec29 /source3/include/g_lock.h
parent30797cec7d826a75e6e458829fc3b2203d841ba3 (diff)
downloadsamba-4c1c3f2549f32fd069e0e7bf3aec299213f1e85b.tar.gz
samba-4c1c3f2549f32fd069e0e7bf3aec299213f1e85b.tar.xz
samba-4c1c3f2549f32fd069e0e7bf3aec299213f1e85b.zip
s3: Implement global locks in a g_lock tdb
This is the basis to implement global locks in ctdb without depending on a shared file system. The initial goal is to make ctdb persistent transactions deterministic without too many timeouts.
Diffstat (limited to 'source3/include/g_lock.h')
-rw-r--r--source3/include/g_lock.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/source3/include/g_lock.h b/source3/include/g_lock.h
new file mode 100644
index 00000000000..c0eed38d4b1
--- /dev/null
+++ b/source3/include/g_lock.h
@@ -0,0 +1,55 @@
+/*
+ Unix SMB/CIFS implementation.
+ global locks based on ctdb
+ Copyright (C) 2009 by Volker Lendecke
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _G_LOCK_H_
+#define _G_LOCK_H_
+
+#include "dbwrap.h"
+
+struct g_lock_ctx;
+
+enum g_lock_type {
+ G_LOCK_READ = 0,
+ G_LOCK_WRITE = 1,
+};
+
+/*
+ * Or'ed with g_lock_type
+ */
+#define G_LOCK_PENDING (2)
+
+struct g_lock_ctx *g_lock_ctx_init(TALLOC_CTX *mem_ctx,
+ struct messaging_context *msg);
+
+NTSTATUS g_lock_lock(struct g_lock_ctx *ctx, const char *name,
+ enum g_lock_type lock_type, struct timeval timeout);
+NTSTATUS g_lock_unlock(struct g_lock_ctx *ctx, const char *name);
+NTSTATUS g_lock_get(struct g_lock_ctx *ctx, const char *name,
+ struct server_id *pid);
+
+int g_lock_locks(struct g_lock_ctx *ctx,
+ int (*fn)(const char *name, void *private_data),
+ void *private_data);
+NTSTATUS g_lock_dump(struct g_lock_ctx *ctx, const char *name,
+ int (*fn)(struct server_id pid,
+ enum g_lock_type lock_type,
+ void *private_data),
+ void *private_data);
+
+#endif