summaryrefslogtreecommitdiff
path: root/source3/lib/dbwrap
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2011-07-06 16:49:34 +0200
committerMichael Adam <obnox@samba.org>2011-07-29 12:23:13 +0200
commit2414fc88d85c8dcc22ddbb389255d6c36838cbad (patch)
tree541152a6f4fa0fd538c5a14138928417a7bead1d /source3/lib/dbwrap
parent1abdd9b2bb09d072496db5207814aefefe403f60 (diff)
downloadsamba-2414fc88d85c8dcc22ddbb389255d6c36838cbad.tar.gz
samba-2414fc88d85c8dcc22ddbb389255d6c36838cbad.tar.bz2
samba-2414fc88d85c8dcc22ddbb389255d6c36838cbad.zip
s3:dbwrap: move db_is_local() from dbwrap.c to dbwrap_open.c
Diffstat (limited to 'source3/lib/dbwrap')
-rw-r--r--source3/lib/dbwrap/dbwrap_open.c27
-rw-r--r--source3/lib/dbwrap/dbwrap_open.h6
2 files changed, 33 insertions, 0 deletions
diff --git a/source3/lib/dbwrap/dbwrap_open.c b/source3/lib/dbwrap/dbwrap_open.c
index d6b2f30ef6..8721b1b0f9 100644
--- a/source3/lib/dbwrap/dbwrap_open.c
+++ b/source3/lib/dbwrap/dbwrap_open.c
@@ -27,6 +27,33 @@
#include "ctdb_private.h"
#endif
+bool db_is_local(const char *name)
+{
+#ifdef CLUSTER_SUPPORT
+ const char *sockname = lp_ctdbd_socket();
+
+ if(!sockname || !*sockname) {
+ sockname = CTDB_PATH;
+ }
+
+ if (lp_clustering() && socket_exist(sockname)) {
+ const char *partname;
+ /* ctdb only wants the file part of the name */
+ partname = strrchr(name, '/');
+ if (partname) {
+ partname++;
+ } else {
+ partname = name;
+ }
+ /* allow ctdb for individual databases to be disabled */
+ if (lp_parm_bool(-1, "ctdb", partname, True)) {
+ return false;
+ }
+ }
+#endif
+ return true;
+}
+
/**
* open a database
*/
diff --git a/source3/lib/dbwrap/dbwrap_open.h b/source3/lib/dbwrap/dbwrap_open.h
index 153e91ad5d..5a172a4a2a 100644
--- a/source3/lib/dbwrap/dbwrap_open.h
+++ b/source3/lib/dbwrap/dbwrap_open.h
@@ -24,6 +24,12 @@
struct db_context;
/**
+ * Convenience function to check whether a tdb database
+ * is local or clustered (ctdb) in a clustered environment.
+ */
+bool db_is_local(const char *name);
+
+/**
* Convenience function that will determine whether to
* open a tdb database via the tdb backend or via the ctdb
* backend, based on lp_clustering() and a db-specific