>From eecde84606636671791059fbd7b0723d9ed28a43 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 8 Oct 2013 12:10:54 +0200 Subject: [PATCH 01/14] wafsamba: add CONFIG_RESET() Signed-off-by: Stefan Metzmacher --- buildtools/wafsamba/samba_autoconf.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py index e14f9cd..e726536 100644 --- a/buildtools/wafsamba/samba_autoconf.py +++ b/buildtools/wafsamba/samba_autoconf.py @@ -495,6 +495,14 @@ def CONFIG_SET(conf, option): if v == (): return False return True + +@conf +def CONFIG_RESET(conf, option): + if option not in conf.env: + return + del conf.env[option] + +Build.BuildContext.CONFIG_RESET = CONFIG_RESET Build.BuildContext.CONFIG_SET = CONFIG_SET Build.BuildContext.CONFIG_GET = CONFIG_GET -- 1.7.9.5 >From 2154ce0585e98696c6fbbc2cd43e13b69fbd267d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 8 Oct 2013 11:52:23 +0200 Subject: [PATCH 02/14] s3:wscript: create a libsamba-cluster-support.so This collects the ctdb version dependent files, which allows vendors to provide multiple versions of libsamba-cluster-support.so each compiled against different ctdb versions. Signed-off-by: Stefan Metzmacher --- source3/wscript_build | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/source3/wscript_build b/source3/wscript_build index 12e473f..d5f88a1 100755 --- a/source3/wscript_build +++ b/source3/wscript_build @@ -270,21 +270,32 @@ bld.SAMBA3_SUBSYSTEM('samba3util', lib/sock_exec.c''', deps='ndr samba-security NDR_SECURITY samba-util util_tdb ccan-hash') +bld.SAMBA3_LIBRARY('samba-cluster-support', + source=''' + lib/dbwrap/dbwrap_ctdb.c + lib/messages_ctdbd.c + lib/ctdb_packet.c + lib/ctdbd_conn.c + lib/ctdb_conn.c + torture/test_ctdbconn.c + ''', + deps=''' + talloc + tevent + tdb + ''', + allow_undefined_symbols=True, + private_library=True) bld.SAMBA3_SUBSYSTEM('TDB_LIB', source='''lib/dbwrap/dbwrap_open.c - lib/dbwrap/dbwrap_ctdb.c lib/dbwrap/dbwrap_watch.c lib/g_lock.c''', - deps='dbwrap') + deps='dbwrap samba-cluster-support') bld.SAMBA3_SUBSYSTEM('samba3core', source='''lib/messages.c lib/messages_local.c - lib/messages_ctdbd.c - lib/ctdb_packet.c - lib/ctdbd_conn.c - lib/ctdb_conn.c lib/util_cluster.c lib/id_cache.c lib/talloc_dict.c @@ -1209,7 +1220,6 @@ bld.SAMBA3_BINARY('smbtorture' + bld.env.suffix3, torture/test_authinfo_structs.c torture/test_smbsock_any_connect.c torture/test_cleanup.c - torture/test_ctdbconn.c torture/test_notify.c lib/tevent_barrier.c torture/test_dbwrap_watch.c @@ -1229,6 +1239,7 @@ bld.SAMBA3_BINARY('smbtorture' + bld.env.suffix3, LOCKING NDR_OPEN_FILES idmap + samba-cluster-support ''', install=False) -- 1.7.9.5 >From 5cc1237f2e12f8b23534ab47a0a6a8651ef418d1 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 8 Oct 2013 15:30:16 +0200 Subject: [PATCH 03/14] s3:ctdbd_conn: add ctdb_serverids_exist_supported() Signed-off-by: Stefan Metzmacher --- source3/include/ctdbd_conn.h | 1 + source3/lib/ctdbd_conn.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h index ce5c8ba..50e8e7e 100644 --- a/source3/include/ctdbd_conn.h +++ b/source3/include/ctdbd_conn.h @@ -49,6 +49,7 @@ bool ctdbd_process_exists(struct ctdbd_connection *conn, uint32_t vnn, bool ctdb_processes_exist(struct ctdbd_connection *conn, const struct server_id *pids, int num_pids, bool *results); +bool ctdb_serverids_exist_supported(struct ctdbd_connection *conn); bool ctdb_serverids_exist(struct ctdbd_connection *conn, const struct server_id *pids, unsigned num_pids, bool *results); diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c index 6ab4bbe..614b9ec 100644 --- a/source3/lib/ctdbd_conn.c +++ b/source3/lib/ctdbd_conn.c @@ -1121,6 +1121,15 @@ fail: return false; } +bool ctdb_serverids_exist_supported(struct ctdbd_connection *conn) +{ +#ifndef HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL + return false; +#else /* HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL */ + return true; +#endif /* HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL */ +} + #ifdef HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL bool ctdb_serverids_exist(struct ctdbd_connection *conn, -- 1.7.9.5 >From 3e131d44a65a1ed67467dc94f06ec2942caf8ee5 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 8 Oct 2013 15:30:44 +0200 Subject: [PATCH 04/14] s3:ctdbd_conn: always provide ctdb_serverids_exist() Signed-off-by: Stefan Metzmacher --- source3/lib/ctdbd_conn.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c index 614b9ec..f2562bc 100644 --- a/source3/lib/ctdbd_conn.c +++ b/source3/lib/ctdbd_conn.c @@ -1130,12 +1130,13 @@ bool ctdb_serverids_exist_supported(struct ctdbd_connection *conn) #endif /* HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL */ } -#ifdef HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL - bool ctdb_serverids_exist(struct ctdbd_connection *conn, const struct server_id *pids, unsigned num_pids, bool *results) { +#ifndef HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL + return false; +#else /* HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL */ unsigned i, num_received; NTSTATUS status; struct ctdb_vnn_list *vnns = NULL; @@ -1281,9 +1282,8 @@ bool ctdb_serverids_exist(struct ctdbd_connection *conn, fail: TALLOC_FREE(vnns); return result; -} - #endif /* HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL */ +} /* * Get a db path -- 1.7.9.5 >From 9979189e05df4b43b5d72260b70c74fb461cc697 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 21 Jan 2014 14:25:32 +0100 Subject: [PATCH 05/14] s3:lib: move all ctdb related dummy functions to ctdb_dummy.c This gets all dummy functions for the build without CLUSTER_SUPPORT. Signed-off-by: Stefan Metzmacher --- source3/lib/ctdb_conn.c | 72 --------------- source3/lib/ctdb_dummy.c | 179 ++++++++++++++++++++++++++++++++++++++ source3/lib/ctdbd_conn.c | 14 --- source3/lib/dbwrap/dbwrap_ctdb.c | 14 --- source3/lib/messages_ctdbd.c | 14 --- source3/torture/test_ctdbconn.c | 7 -- source3/wscript_build | 1 + 7 files changed, 180 insertions(+), 121 deletions(-) create mode 100644 source3/lib/ctdb_dummy.c diff --git a/source3/lib/ctdb_conn.c b/source3/lib/ctdb_conn.c index 40071d4..8e21b9a 100644 --- a/source3/lib/ctdb_conn.c +++ b/source3/lib/ctdb_conn.c @@ -546,76 +546,4 @@ int ctdb_msg_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, return 0; } -#else - -struct dummy_state { - uint8_t dummy; -}; - -static struct tevent_req *dummy_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev) -{ - struct tevent_req *req; - struct dummy_state *state; - req = tevent_req_create(mem_ctx, &state, struct dummy_state); - if (req == NULL) { - return NULL; - } - tevent_req_done(req); - return tevent_req_post(req, ev); -} - -struct tevent_req *ctdb_conn_init_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, - const char *sock) -{ - return dummy_send(mem_ctx, ev); -} - -int ctdb_conn_init_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, - struct ctdb_conn **pconn) -{ - return ENOSYS; -} - -struct tevent_req *ctdb_conn_msg_write_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, - struct ctdb_conn *conn, - uint32_t vnn, uint64_t srvid, - uint8_t *msg, size_t msg_len) -{ - return dummy_send(mem_ctx, ev); -} - -int ctdb_conn_msg_write_recv(struct tevent_req *req) -{ - return ENOSYS; -} - -struct tevent_req *ctdb_msg_channel_init_send( - TALLOC_CTX *mem_ctx, struct tevent_context *ev, - const char *sock, uint64_t srvid) -{ - return dummy_send(mem_ctx, ev); -} - -int ctdb_msg_channel_init_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, - struct ctdb_msg_channel **pchannel) -{ - return ENOSYS; -} - -struct tevent_req *ctdb_msg_read_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, - struct ctdb_msg_channel *channel) -{ - return dummy_send(mem_ctx, ev); -} - -int ctdb_msg_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, - uint8_t **pmsg, size_t *pmsg_len) -{ - return ENOSYS; -} - #endif diff --git a/source3/lib/ctdb_dummy.c b/source3/lib/ctdb_dummy.c new file mode 100644 index 0000000..fe32c9c --- /dev/null +++ b/source3/lib/ctdb_dummy.c @@ -0,0 +1,179 @@ +/* + Unix SMB/CIFS implementation. + Copyright (C) 2014 Björn Baumbach + Copyright (C) 2014 Stefan Metzmacher + + 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 . +*/ + +#include "includes.h" +#include "messages.h" +#include "ctdb_conn.h" +#include "ctdbd_conn.h" +#include "lib/dbwrap/dbwrap.h" +#include "lib/dbwrap/dbwrap_ctdb.h" +#include "torture/proto.h" + +#ifndef CLUSTER_SUPPORT + +NTSTATUS ctdbd_probe(void) +{ + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS ctdbd_messaging_send_blob(struct ctdbd_connection *conn, + uint32_t dst_vnn, uint64_t dst_srvid, + const uint8_t *buf, size_t buflen) +{ + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid) +{ + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS ctdbd_register_reconfigure(struct ctdbd_connection *conn) +{ + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn, + const struct sockaddr_storage *_server, + const struct sockaddr_storage *_client, + void (*release_ip_handler)(const char *ip_addr, + void *private_data), + void *private_data) +{ + return NT_STATUS_NOT_IMPLEMENTED; +} + +bool ctdb_serverids_exist_supported(struct ctdbd_connection *conn) +{ + return false; +} + +bool ctdb_serverids_exist(struct ctdbd_connection *conn, + const struct server_id *pids, unsigned num_pids, + bool *results) +{ + return false; +} + +bool ctdb_processes_exist(struct ctdbd_connection *conn, + const struct server_id *pids, int num_pids, + bool *results) +{ + return false; +} + +struct dummy_state { + uint8_t dummy; +}; + +static struct tevent_req *dummy_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev) +{ + struct tevent_req *req; + struct dummy_state *state; + req = tevent_req_create(mem_ctx, &state, struct dummy_state); + if (req == NULL) { + return NULL; + } + tevent_req_done(req); + return tevent_req_post(req, ev); +} + +struct tevent_req *ctdb_conn_init_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + const char *sock) +{ + return dummy_send(mem_ctx, ev); +} + +int ctdb_conn_init_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, + struct ctdb_conn **pconn) +{ + return ENOSYS; +} + +struct tevent_req *ctdb_conn_msg_write_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct ctdb_conn *conn, + uint32_t vnn, uint64_t srvid, + uint8_t *msg, size_t msg_len) +{ + return dummy_send(mem_ctx, ev); +} + +int ctdb_conn_msg_write_recv(struct tevent_req *req) +{ + return ENOSYS; +} + +struct tevent_req *ctdb_msg_channel_init_send( + TALLOC_CTX *mem_ctx, struct tevent_context *ev, + const char *sock, uint64_t srvid) +{ + return dummy_send(mem_ctx, ev); +} + +int ctdb_msg_channel_init_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, + struct ctdb_msg_channel **pchannel) +{ + return ENOSYS; +} + +struct tevent_req *ctdb_msg_read_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct ctdb_msg_channel *channel) +{ + return dummy_send(mem_ctx, ev); +} + +int ctdb_msg_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, + uint8_t **pmsg, size_t *pmsg_len) +{ + return ENOSYS; +} + +struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx, + const char *name, + int hash_size, int tdb_flags, + int open_flags, mode_t mode, + enum dbwrap_lock_order lock_order, + uint64_t dbwrap_flags) +{ + errno = ENOSYS; + return NULL; +} + +NTSTATUS messaging_ctdbd_init(struct messaging_context *msg_ctx, + TALLOC_CTX *mem_ctx, + struct messaging_backend **presult) +{ + return NT_STATUS_NOT_IMPLEMENTED; +} + +struct ctdbd_connection *messaging_ctdbd_connection(void) +{ + return NULL; +} + +bool run_ctdb_conn(int dummy) +{ + return true; +} + +#endif diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c index f2562bc..e4c63f6 100644 --- a/source3/lib/ctdbd_conn.c +++ b/source3/lib/ctdbd_conn.c @@ -1850,18 +1850,4 @@ NTSTATUS ctdbd_probe(void) return status; } -#else - -NTSTATUS ctdbd_probe(void) -{ - return NT_STATUS_OK; -} - -NTSTATUS ctdbd_messaging_send_blob(struct ctdbd_connection *conn, - uint32_t dst_vnn, uint64_t dst_srvid, - const uint8_t *buf, size_t buflen) -{ - return NT_STATUS_NOT_IMPLEMENTED; -} - #endif diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c index 87e644d..6888d2e 100644 --- a/source3/lib/dbwrap/dbwrap_ctdb.c +++ b/source3/lib/dbwrap/dbwrap_ctdb.c @@ -1719,18 +1719,4 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx, return result; } -#else /* CLUSTER_SUPPORT */ - -struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx, - const char *name, - int hash_size, int tdb_flags, - int open_flags, mode_t mode, - enum dbwrap_lock_order lock_order, - uint64_t dbwrap_flags) -{ - DEBUG(3, ("db_open_ctdb: no cluster support!\n")); - errno = ENOSYS; - return NULL; -} - #endif diff --git a/source3/lib/messages_ctdbd.c b/source3/lib/messages_ctdbd.c index 234f8f9..200734d 100644 --- a/source3/lib/messages_ctdbd.c +++ b/source3/lib/messages_ctdbd.c @@ -169,18 +169,4 @@ NTSTATUS messaging_ctdbd_init(struct messaging_context *msg_ctx, return NT_STATUS_OK; } -#else - -NTSTATUS messaging_ctdbd_init(struct messaging_context *msg_ctx, - TALLOC_CTX *mem_ctx, - struct messaging_backend **presult) -{ - return NT_STATUS_NOT_IMPLEMENTED; -} - -struct ctdbd_connection *messaging_ctdbd_connection(void) -{ - return NULL; -} - #endif diff --git a/source3/torture/test_ctdbconn.c b/source3/torture/test_ctdbconn.c index 149f06d..7b30288 100644 --- a/source3/torture/test_ctdbconn.c +++ b/source3/torture/test_ctdbconn.c @@ -243,11 +243,4 @@ bool run_ctdb_conn(int dummy) return (ret == 0); } -#else /* CLUSTER_SUPPORT */ - -bool run_ctdb_conn(int dummy) -{ - return true; -} - #endif diff --git a/source3/wscript_build b/source3/wscript_build index d5f88a1..56c54c0 100755 --- a/source3/wscript_build +++ b/source3/wscript_build @@ -272,6 +272,7 @@ bld.SAMBA3_SUBSYSTEM('samba3util', bld.SAMBA3_LIBRARY('samba-cluster-support', source=''' + lib/ctdb_dummy.c lib/dbwrap/dbwrap_ctdb.c lib/messages_ctdbd.c lib/ctdb_packet.c -- 1.7.9.5 >From 36a1768e548566c1eaf4a81364396b7c1ff7c468 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 8 Oct 2013 13:33:49 +0200 Subject: [PATCH 06/14] s3:param: move lp_ctdbd_socket() to ctdbd_conn.c This allows us to use CTDB_PATH only in ctdbd_conn.c Signed-off-by: Stefan Metzmacher --- docs-xml/smbdotconf/misc/ctdbdsocket.xml | 3 ++- lib/param/param_table.c | 2 +- source3/include/ctdbd_conn.h | 1 + source3/lib/ctdb_dummy.c | 5 +++++ source3/lib/ctdbd_conn.c | 12 ++++++++++++ source3/lib/dbwrap/dbwrap_open.c | 4 +--- source3/param/loadparm.c | 10 +--------- source3/torture/test_ctdbconn.c | 1 + 8 files changed, 24 insertions(+), 14 deletions(-) diff --git a/docs-xml/smbdotconf/misc/ctdbdsocket.xml b/docs-xml/smbdotconf/misc/ctdbdsocket.xml index 378d6e2..27e8121 100644 --- a/docs-xml/smbdotconf/misc/ctdbdsocket.xml +++ b/docs-xml/smbdotconf/misc/ctdbdsocket.xml @@ -1,8 +1,9 @@ If you set clustering=yes, diff --git a/lib/param/param_table.c b/lib/param/param_table.c index ad929ec..40f8eb5 100644 --- a/lib/param/param_table.c +++ b/lib/param/param_table.c @@ -1938,7 +1938,7 @@ static struct parm_struct parm_table[] = { .label = "ctdbd socket", .type = P_STRING, .p_class = P_GLOBAL, - .offset = GLOBAL_VAR(ctdbd_socket), + .offset = GLOBAL_VAR(_ctdbd_socket), .special = NULL, .enum_list = NULL, .flags = FLAG_ADVANCED | FLAG_GLOBAL, diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h index 50e8e7e..3907fd8 100644 --- a/source3/include/ctdbd_conn.h +++ b/source3/include/ctdbd_conn.h @@ -30,6 +30,7 @@ NTSTATUS ctdbd_messaging_connection(TALLOC_CTX *mem_ctx, struct ctdbd_connection **pconn); uint32_t ctdbd_vnn(const struct ctdbd_connection *conn); +const char *lp_ctdbd_socket(void); NTSTATUS ctdbd_register_msg_ctx(struct ctdbd_connection *conn, struct messaging_context *msg_ctx); diff --git a/source3/lib/ctdb_dummy.c b/source3/lib/ctdb_dummy.c index fe32c9c..16c2532 100644 --- a/source3/lib/ctdb_dummy.c +++ b/source3/lib/ctdb_dummy.c @@ -59,6 +59,11 @@ NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn, return NT_STATUS_NOT_IMPLEMENTED; } +const char *lp_ctdbd_socket(void) +{ + return ""; +} + bool ctdb_serverids_exist_supported(struct ctdbd_connection *conn) { return false; diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c index e4c63f6..f273037 100644 --- a/source3/lib/ctdbd_conn.c +++ b/source3/lib/ctdbd_conn.c @@ -194,6 +194,18 @@ uint32_t ctdbd_vnn(const struct ctdbd_connection *conn) return conn->our_vnn; } +const char *lp_ctdbd_socket(void) +{ + const char *ret; + + ret = lp__ctdbd_socket(); + if (ret != NULL && strlen(ret) > 0) { + return ret; + } + + return CTDB_PATH; +} + /* * Get us a ctdb connection */ diff --git a/source3/lib/dbwrap/dbwrap_open.c b/source3/lib/dbwrap/dbwrap_open.c index 3c8756b..021ebc3 100644 --- a/source3/lib/dbwrap/dbwrap_open.c +++ b/source3/lib/dbwrap/dbwrap_open.c @@ -26,9 +26,7 @@ #include "dbwrap/dbwrap_ctdb.h" #include "lib/param/param.h" #include "util_tdb.h" -#ifdef CLUSTER_SUPPORT -#include "ctdb_private.h" -#endif +#include "ctdbd_conn.h" bool db_is_local(const char *name) { diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index f2d1e6b..66c4ef8 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -78,10 +78,6 @@ #include #endif -#ifdef CLUSTER_SUPPORT -#include "ctdb_private.h" -#endif - bool bLoaded = false; extern userdom_struct current_user_info; @@ -934,11 +930,7 @@ static void init_globals(bool reinit_globals) string_set(&Globals.cups_server, ""); string_set(&Globals.iprint_server, ""); -#ifdef CLUSTER_SUPPORT - string_set(&Globals.ctdbd_socket, CTDB_PATH); -#else - string_set(&Globals.ctdbd_socket, ""); -#endif + string_set(&Globals._ctdbd_socket, ""); Globals.cluster_addresses = NULL; Globals.clustering = false; diff --git a/source3/torture/test_ctdbconn.c b/source3/torture/test_ctdbconn.c index 7b30288..d8f744c 100644 --- a/source3/torture/test_ctdbconn.c +++ b/source3/torture/test_ctdbconn.c @@ -23,6 +23,7 @@ #ifdef CLUSTER_SUPPORT #include "ctdb_conn.h" +#include "ctdbd_conn.h" #include "lib/util/tevent_unix.h" #include "tdb.h" -- 1.7.9.5 >From 5013333c0f3a6703f98723b049d03ea6b749efd2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 21 Jan 2014 14:32:30 +0100 Subject: [PATCH 07/14] s3:lib: add cluster_support_[available|features]() This allows runtime selection of libsamba-cluster-support.so Signed-off-by: Stefan Metzmacher --- source3/lib/cluster_support.c | 91 +++++++++++++++++++++++++++++++++++++++++ source3/lib/cluster_support.h | 20 +++++++++ source3/wscript_build | 1 + 3 files changed, 112 insertions(+) create mode 100644 source3/lib/cluster_support.c create mode 100644 source3/lib/cluster_support.h diff --git a/source3/lib/cluster_support.c b/source3/lib/cluster_support.c new file mode 100644 index 0000000..4642367 --- /dev/null +++ b/source3/lib/cluster_support.c @@ -0,0 +1,91 @@ +/* + Unix SMB/CIFS implementation. + Copyright (C) 2014 Stefan Metzmacher + + 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 . +*/ + +#include "includes.h" +#include +#include "cluster_support.h" + +#ifdef HAVE_CTDB_H +#include +#endif + +#ifdef HAVE_CTDB_PROTOCOL_H +#include +#else +#ifdef HAVE_CTDB_PRIVATE_H +#include +#endif +#endif + +bool cluster_support_available(void) +{ +#ifdef CLUSTER_SUPPORT + return true; +#else + return false; +#endif +} + +const char *cluster_support_features(void) +{ +#define _LINE_DEF(x) " " #x "\n" +#define _LINE_STR(x) " " #x ": " x "\n" +#define _LINE_INT(x) " " #x ": " __STRINGSTRING(x) "\n" + static const char *v = "Cluster support features:\n" +#ifdef CLUSTER_SUPPORT + _LINE_DEF(CLUSTER_SUPPORT) +#else + " NONE\n" +#endif +#ifdef HAVE_CTDB_H + _LINE_DEF(HAVE_CTDB_H) +#endif +#ifdef HAVE_CTDB_PRIVATE_H + _LINE_DEF(HAVE_CTDB_PRIVATE_H) +#endif +#ifdef HAVE_CTDB_PROTOCOL_H + _LINE_DEF(HAVE_CTDB_PROTOCOL_H) +#endif +#ifdef HAVE_CTDB_CONTROL_TRANS3_COMMIT_DECL + _LINE_DEF(HAVE_CTDB_CONTROL_TRANS3_COMMIT_DECL) +#endif +#ifdef HAVE_CTDB_CONTROL_SCHEDULE_FOR_DELETION_DECL + _LINE_DEF(HAVE_CTDB_CONTROL_SCHEDULE_FOR_DELETION_DECL) +#endif +#ifdef HAVE_CTDB_WANT_READONLY_DECL + _LINE_DEF(HAVE_CTDB_WANT_READONLY_DECL) +#endif +#ifdef HAVE_STRUCT_CTDB_CONTROL_TCP + _LINE_DEF(HAVE_STRUCT_CTDB_CONTROL_TCP) +#endif +#ifdef HAVE_STRUCT_CTDB_CONTROL_TCP_ADDR + _LINE_DEF(HAVE_STRUCT_CTDB_CONTROL_TCP_ADDR) +#endif +#ifdef HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL + _LINE_DEF(HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL) +#endif +#ifdef CTDB_PATH + _LINE_STR(CTDB_PATH) +#endif +#ifdef CTDB_VERSION + _LINE_INT(CTDB_VERSION) +#endif + ""; + + return v; +} diff --git a/source3/lib/cluster_support.h b/source3/lib/cluster_support.h new file mode 100644 index 0000000..0a03d2b --- /dev/null +++ b/source3/lib/cluster_support.h @@ -0,0 +1,20 @@ +/* + Unix SMB/CIFS implementation. + Copyright (C) 2014 Stefan Metzmacher + + 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 . +*/ + +bool cluster_support_available(void); +const char *cluster_support_features(void); diff --git a/source3/wscript_build b/source3/wscript_build index 56c54c0..1bc3a55 100755 --- a/source3/wscript_build +++ b/source3/wscript_build @@ -272,6 +272,7 @@ bld.SAMBA3_SUBSYSTEM('samba3util', bld.SAMBA3_LIBRARY('samba-cluster-support', source=''' + lib/cluster_support.c lib/ctdb_dummy.c lib/dbwrap/dbwrap_ctdb.c lib/messages_ctdbd.c -- 1.7.9.5 >From 141c693b693d1063ee7dfb9a744f90d3396dd6da Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 21 Jan 2014 14:32:49 +0100 Subject: [PATCH 08/14] wafsamba: use cluster_support_features in build_options.c This way 'smbd -b' returns the cluster features of the currently used libsamba-cluster-support.so. Signed-off-by: Stefan Metzmacher --- buildtools/wafsamba/samba_patterns.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/buildtools/wafsamba/samba_patterns.py b/buildtools/wafsamba/samba_patterns.py index 55ed540..1e2df90 100644 --- a/buildtools/wafsamba/samba_patterns.py +++ b/buildtools/wafsamba/samba_patterns.py @@ -59,6 +59,8 @@ def write_build_options_header(fp): fp.write("#include \"includes.h\"\n") fp.write("#include \"build_env.h\"\n") fp.write("#include \"dynconfig/dynconfig.h\"\n") + fp.write("#include \"lib/cluster_support.h\"\n") + fp.write("\n") fp.write("static int output(bool screen, const char *format, ...) PRINTF_ATTRIBUTE(2,3);\n") fp.write("void build_options(bool screen);\n") @@ -129,6 +131,9 @@ def write_build_options_header(fp): fp.write("\n") def write_build_options_footer(fp): + fp.write(" /* Output the sizes of the various cluster features */\n") + fp.write(" output(screen, \"\\n%s\", cluster_support_features());\n") + fp.write("\n") fp.write(" /* Output the sizes of the various types */\n") fp.write(" output(screen, \"\\nType sizes:\\n\");\n") fp.write(" output(screen, \" sizeof(char): %lu\\n\",(unsigned long)sizeof(char));\n") -- 1.7.9.5 >From 957abf2bd63d668d54184967bb7fe1573d9e2110 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 8 Oct 2013 13:35:41 +0200 Subject: [PATCH 09/14] s3:ctdb_conn: only use ctdb_protocol.h or ctdb_private.h in ctdb_conn.c We don't need them in ctdb_conn.h. Signed-off-by: Stefan Metzmacher --- source3/lib/ctdb_conn.c | 8 ++++++++ source3/lib/ctdb_conn.h | 17 +---------------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/source3/lib/ctdb_conn.c b/source3/lib/ctdb_conn.c index 8e21b9a..214ea97 100644 --- a/source3/lib/ctdb_conn.c +++ b/source3/lib/ctdb_conn.c @@ -23,6 +23,14 @@ #ifdef CLUSTER_SUPPORT +#include + +#ifdef HAVE_CTDB_PROTOCOL_H +#include +#else +#include +#endif + #include "lib/async_req/async_sock.h" struct ctdb_conn { diff --git a/source3/lib/ctdb_conn.h b/source3/lib/ctdb_conn.h index 0d648c7..21a69c7 100644 --- a/source3/lib/ctdb_conn.h +++ b/source3/lib/ctdb_conn.h @@ -20,26 +20,11 @@ #ifndef _CTDB_CONN_H #define _CTDB_CONN_H -#ifdef CLUSTER_SUPPORT - -#include - -#ifdef HAVE_CTDB_PROTOCOL_H -#include -#else -#include -#endif - -#else /* CLUSTER_SUPPORT */ - -struct ctdb_reply_control; - -#endif /* CLUSTER_SUPPORT */ - #include "tevent.h" #include "librpc/gen_ndr/messaging.h" struct ctdb_conn; +struct ctdb_reply_control; struct tevent_req *ctdb_conn_control_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, -- 1.7.9.5 >From fd8a55c4643c7ddbbaa9074d6f9c69fefec577ba Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 8 Oct 2013 15:31:17 +0200 Subject: [PATCH 10/14] s3:serverid: use ctdb_serverids_exist_supported() runtime check This is better than a compile time check for HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL. Signed-off-by: Stefan Metzmacher --- source3/lib/serverid.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/source3/lib/serverid.c b/source3/lib/serverid.c index 4259887..b69671e 100644 --- a/source3/lib/serverid.c +++ b/source3/lib/serverid.c @@ -126,11 +126,13 @@ bool serverid_register(const struct server_id id, uint32_t msg_flags) nt_errstr(status))); goto done; } -#ifdef HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL - if (lp_clustering()) { + + if (lp_clustering() && + ctdb_serverids_exist_supported(messaging_ctdbd_connection())) + { register_with_ctdbd(messaging_ctdbd_connection(), id.unique_id); } -#endif + ret = true; done: TALLOC_FREE(rec); @@ -341,8 +343,10 @@ bool serverids_exist(const struct server_id *ids, int num_ids, bool *results) remote_num += 1; } -#ifdef HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL - if (remote_num != 0) { +#ifdef CLUSTER_SUPPORT + if (remote_num != 0 && + ctdb_serverids_exist_supported(messaging_ctdbd_connection())) + { int old_remote_num = remote_num; remote_num = 0; -- 1.7.9.5 >From 8bcb708df00be19c59b764cfe81a14a1e2d847a7 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 8 Oct 2013 12:11:49 +0200 Subject: [PATCH 11/14] s3:wscript: don't add ctdb include dir globally Signed-off-by: Stefan Metzmacher --- source3/wscript | 14 +++++++++----- source3/wscript_build | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/source3/wscript b/source3/wscript index af0ed9f..ca4695d 100644 --- a/source3/wscript +++ b/source3/wscript @@ -1430,8 +1430,9 @@ main() { else: - if Options.options.ctdb_dir: - conf.ADD_EXTRA_INCLUDES(Options.options.ctdb_dir + '/include') + have_cluster_support = True + ctdb_broken = "" + CTDB_CFLAGS = "" srcdir = os.path.realpath(conf.srcdir) if 'EXTRA_INCLUDES' in conf.env: @@ -1439,15 +1440,16 @@ main() { else: includes = '' + if Options.options.ctdb_dir: + CTDB_CFLAGS = '-I' + Options.options.ctdb_dir + '/include' + includes = includes + ' ' + Options.options.ctdb_dir + '/include' + if not conf.env.USING_SYSTEM_TDB: includes = includes + ' ' + srcdir + '/lib/tdb/include' if not conf.env.USING_SYSTEM_TALLOC: includes = includes + ' ' + srcdir + '/lib/talloc' - have_cluster_support = True - ctdb_broken = "" - conf.CHECK_CODE(''' #define NO_CONFIG_H #include "replace.h" @@ -1683,6 +1685,7 @@ main() { if have_cluster_support: Logs.info("building with cluster support") conf.DEFINE('CLUSTER_SUPPORT', 1); + conf.env['CTDB_CFLAGS'] = CTDB_CFLAGS else: if Options.options.with_cluster_support == False: Logs.info("building without cluster support (--without-cluster-support)") @@ -1691,6 +1694,7 @@ main() { conf.fatal("Cluster support not found, but --with-cluster-support was specified") else: Logs.info("building without cluster support: " + ctdb_broken) + conf.env['CTDB_CFLAGS'] = '' conf.undefine('CLUSTER_SUPPORT') diff --git a/source3/wscript_build b/source3/wscript_build index 1bc3a55..c3f5fdc 100755 --- a/source3/wscript_build +++ b/source3/wscript_build @@ -286,6 +286,7 @@ bld.SAMBA3_LIBRARY('samba-cluster-support', tevent tdb ''', + cflags=bld.CONFIG_GET("CTDB_CFLAGS"), allow_undefined_symbols=True, private_library=True) -- 1.7.9.5 >From 0e6df1f91fc1c824c5f1fa2f9a6c257fc0916073 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 8 Oct 2013 12:56:02 +0200 Subject: [PATCH 12/14] s3:wscript: only fill in CTDB_CFLAGS instead of config.h Only files in 'samba3-ctdb-client' will see HAVE_CTDB* defines. Signed-off-by: Stefan Metzmacher --- source3/wscript | 85 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 53 insertions(+), 32 deletions(-) diff --git a/source3/wscript b/source3/wscript index ca4695d..eff1e2c 100644 --- a/source3/wscript +++ b/source3/wscript @@ -1450,7 +1450,7 @@ main() { if not conf.env.USING_SYSTEM_TALLOC: includes = includes + ' ' + srcdir + '/lib/talloc' - conf.CHECK_CODE(''' + ok = conf.CHECK_CODE(''' #define NO_CONFIG_H #include "replace.h" #include "system/wait.h" @@ -1465,17 +1465,19 @@ main() { return 0; } ''', - 'HAVE_CTDB_H', + 'HAVE_CTDB_CHECK_CODE', addmain=False, includes=includes, msg='Checking for header ctdb.h') - - if not conf.CONFIG_SET('HAVE_CTDB_H'): + if ok: + CTDB_CFLAGS += ' -DHAVE_CTDB_H=1' + else: have_cluster_support = False ctdb_broken = "ctdb.h is required for cluster support" + conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE') if have_cluster_support: - conf.CHECK_CODE(''' + ok = conf.CHECK_CODE(''' #define NO_CONFIG_H #include "replace.h" #include "system/wait.h" @@ -1491,17 +1493,19 @@ main() { return 0; } ''', - 'HAVE_CTDB_PRIVATE_H', + 'HAVE_CTDB_CHECK_CODE', addmain=False, includes=includes, msg='Checking for header ctdb_private.h') - - if not conf.CONFIG_SET('HAVE_CTDB_PRIVATE_H'): + if ok: + CTDB_CFLAGS += ' -DHAVE_CTDB_PRIVATE_H=1' + else: have_cluster_support = False ctdb_broken = "ctdb_private.h is required for cluster support" + conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE') if have_cluster_support: - conf.CHECK_CODE(''' + ok = conf.CHECK_CODE(''' #define NO_CONFIG_H #include "replace.h" #include "system/wait.h" @@ -1517,13 +1521,16 @@ main() { return 0; } ''', - 'HAVE_CTDB_PROTOCOL_H', + 'HAVE_CTDB_CHECK_CODE', addmain=False, includes=includes, msg='Checking for header ctdb_protocol.h') + if ok: + CTDB_CFLAGS += ' -DHAVE_CTDB_PROTOCOL_H=1' + conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE') if have_cluster_support: - conf.CHECK_CODE(''' + ok = conf.CHECK_CODE(''' #define NO_CONFIG_H #include "replace.h" #include "system/wait.h" @@ -1539,17 +1546,19 @@ main() { return 0; } ''', - 'HAVE_CTDB_CONTROL_TRANS3_COMMIT_DECL', + 'HAVE_CTDB_CHECK_CODE', addmain=False, includes=includes, msg='Checking for transaction support (TRANS3_COMMIT control)') - - if not conf.CONFIG_SET('HAVE_CTDB_CONTROL_TRANS3_COMMIT_DECL'): + if ok: + CTDB_CFLAGS += ' -DHAVE_CTDB_CONTROL_TRANS3_COMMIT_DECL=1' + else: have_cluster_support = False ctdb_broken = "ctdb transaction support missing or too old" + conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE') if have_cluster_support: - conf.CHECK_CODE(''' + ok = conf.CHECK_CODE(''' #define NO_CONFIG_H #include "replace.h" #include "system/wait.h" @@ -1565,20 +1574,22 @@ main() { return 0; } ''', - 'HAVE_CTDB_CONTROL_SCHEDULE_FOR_DELETION_DECL', + 'HAVE_CTDB_CHECK_CODE', addmain=False, includes=includes, msg='Checking for SCHEDULE_FOR_DELETION control') - - if not conf.CONFIG_SET('HAVE_CTDB_CONTROL_SCHEDULE_FOR_DELETION_DECL'): + if ok: + CTDB_CFLAGS += ' -DHAVE_CTDB_CONTROL_SCHEDULE_FOR_DELETION_DECL=1' + else: if not Options.options.enable_old_ctdb: have_cluster_support = False ctdb_broken = "SCHEDULE_FOR_DELETION control missing" else: Logs.warn("ignoring missing SCHEDULE_FOR_DELETION control (--enable-old-ctdb)") + conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE') if have_cluster_support: - conf.CHECK_CODE(''' + ok = conf.CHECK_CODE(''' #define NO_CONFIG_H #include "replace.h" #include "system/wait.h" @@ -1593,20 +1604,22 @@ main() { return 0; } ''', - 'HAVE_CTDB_WANT_READONLY_DECL', + 'HAVE_CTDB_CHECK_CODE', addmain=False, includes=includes, msg='Checking for CTDB readonly records support') - - if not conf.CONFIG_SET('HAVE_CTDB_WANT_READONLY_DECL'): + if ok: + CTDB_CFLAGS += ' -DHAVE_CTDB_WANT_READONLY_DECL=1' + else: if not Options.options.enable_old_ctdb: have_cluster_support = False ctdb_broken = "support for CTDB readonly records missing" else: Logs.warn("ignoring missing READONLY support (--enable-old-ctdb)") + conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE') if have_cluster_support: - conf.CHECK_CODE(''' + ok = conf.CHECK_CODE(''' #define NO_CONFIG_H #include "replace.h" #include "system/wait.h" @@ -1622,17 +1635,19 @@ main() { return 0; } ''', - 'HAVE_STRUCT_CTDB_CONTROL_TCP', + 'HAVE_CTDB_CHECK_CODE', addmain=False, includes=includes, msg='Checking for ctdb ipv4 support') - - if not conf.CONFIG_SET('HAVE_STRUCT_CTDB_CONTROL_TCP'): + if ok: + CTDB_CFLAGS += ' -DHAVE_STRUCT_CTDB_CONTROL_TCP=1' + else: have_cluster_support = False ctdb_broken = "missing struct ctdb_control_tcp" + conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE') if have_cluster_support: - conf.CHECK_CODE(''' + ok = conf.CHECK_CODE(''' #define NO_CONFIG_H #include "replace.h" #include "system/wait.h" @@ -1648,13 +1663,16 @@ main() { return 0; } ''', - 'HAVE_STRUCT_CTDB_CONTROL_TCP_ADDR', + 'HAVE_CTDB_CHECK_CODE', addmain=False, includes=includes, msg='Checking for ctdb ipv6 support') + if ok: + CTDB_CFLAGS += ' -DHAVE_STRUCT_CTDB_CONTROL_TCP_ADDR=1' + conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE') if have_cluster_support: - conf.CHECK_CODE(''' + ok = conf.CHECK_CODE(''' #define NO_CONFIG_H #include "replace.h" #include "system/wait.h" @@ -1670,18 +1688,21 @@ main() { return 0; } ''', - 'HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL', + 'HAVE_CTDB_CHECK_CODE', addmain=False, includes=includes, msg='Checking for CHECK_SRVIDS control') - - if not conf.CONFIG_SET('HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL'): + if ok: + CTDB_CFLAGS += ' -DHAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL=1' + else: if not Options.options.enable_old_ctdb: have_cluster_support = False ctdb_broken = "CHECK_SRVIDS control missing" else: Logs.warn("ignoring missing CHECK_SRVIDS control (--enable-old-ctdb)") + conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE') + conf.undefine('HAVE_CTDB_CHECK_CODE') if have_cluster_support: Logs.info("building with cluster support") conf.DEFINE('CLUSTER_SUPPORT', 1); -- 1.7.9.5 >From 5a84e62ea4b7a45b6cffcdde42d15bb45d72d222 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 21 Jan 2014 15:26:28 +0100 Subject: [PATCH 13/14] s3:wscript: only build ctdb_dummy.c if we have no cluster support Signed-off-by: Stefan Metzmacher --- source3/lib/ctdb_conn.c | 4 ---- source3/lib/ctdb_dummy.c | 4 ---- source3/lib/ctdbd_conn.c | 4 ---- source3/lib/dbwrap/dbwrap_ctdb.c | 4 ---- source3/lib/messages_ctdbd.c | 4 ---- source3/torture/test_ctdbconn.c | 4 ---- source3/wscript_build | 24 ++++++++++++++++++------ 7 files changed, 18 insertions(+), 30 deletions(-) diff --git a/source3/lib/ctdb_conn.c b/source3/lib/ctdb_conn.c index 214ea97..0996511 100644 --- a/source3/lib/ctdb_conn.c +++ b/source3/lib/ctdb_conn.c @@ -21,8 +21,6 @@ #include "lib/util/tevent_unix.h" #include "ctdb_conn.h" -#ifdef CLUSTER_SUPPORT - #include #ifdef HAVE_CTDB_PROTOCOL_H @@ -553,5 +551,3 @@ int ctdb_msg_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, *pmsg_len = msg->datalen; return 0; } - -#endif diff --git a/source3/lib/ctdb_dummy.c b/source3/lib/ctdb_dummy.c index 16c2532..2ff3413 100644 --- a/source3/lib/ctdb_dummy.c +++ b/source3/lib/ctdb_dummy.c @@ -25,8 +25,6 @@ #include "lib/dbwrap/dbwrap_ctdb.h" #include "torture/proto.h" -#ifndef CLUSTER_SUPPORT - NTSTATUS ctdbd_probe(void) { return NT_STATUS_NOT_IMPLEMENTED; @@ -180,5 +178,3 @@ bool run_ctdb_conn(int dummy) { return true; } - -#endif diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c index f273037..9a1ccdb 100644 --- a/source3/lib/ctdbd_conn.c +++ b/source3/lib/ctdbd_conn.c @@ -23,8 +23,6 @@ #include "serverid.h" #include "ctdbd_conn.h" -#ifdef CLUSTER_SUPPORT - #include "ctdb_packet.h" #include "messages.h" @@ -1861,5 +1859,3 @@ NTSTATUS ctdbd_probe(void) return status; } - -#endif diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c index 6888d2e..80150f7 100644 --- a/source3/lib/dbwrap/dbwrap_ctdb.c +++ b/source3/lib/dbwrap/dbwrap_ctdb.c @@ -27,8 +27,6 @@ #include "dbwrap/dbwrap_rbt.h" #include "lib/param/param.h" -#ifdef CLUSTER_SUPPORT - /* * It is not possible to include ctdb.h and tdb_compat.h (included via * some other include above) without warnings. This fixes those @@ -1718,5 +1716,3 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx, return result; } - -#endif diff --git a/source3/lib/messages_ctdbd.c b/source3/lib/messages_ctdbd.c index 200734d..230560f 100644 --- a/source3/lib/messages_ctdbd.c +++ b/source3/lib/messages_ctdbd.c @@ -21,8 +21,6 @@ #include "messages.h" #include "util_tdb.h" -#ifdef CLUSTER_SUPPORT - /* * It is not possible to include ctdb.h and tdb_compat.h (included via * some other include above) without warnings. This fixes those @@ -168,5 +166,3 @@ NTSTATUS messaging_ctdbd_init(struct messaging_context *msg_ctx, *presult = result; return NT_STATUS_OK; } - -#endif diff --git a/source3/torture/test_ctdbconn.c b/source3/torture/test_ctdbconn.c index d8f744c..ff45a02 100644 --- a/source3/torture/test_ctdbconn.c +++ b/source3/torture/test_ctdbconn.c @@ -20,8 +20,6 @@ #include "includes.h" #include "torture/proto.h" -#ifdef CLUSTER_SUPPORT - #include "ctdb_conn.h" #include "ctdbd_conn.h" #include "lib/util/tevent_unix.h" @@ -243,5 +241,3 @@ bool run_ctdb_conn(int dummy) TALLOC_FREE(ev); return (ret == 0); } - -#endif diff --git a/source3/wscript_build b/source3/wscript_build index c3f5fdc..0b01fb8 100755 --- a/source3/wscript_build +++ b/source3/wscript_build @@ -270,22 +270,34 @@ bld.SAMBA3_SUBSYSTEM('samba3util', lib/sock_exec.c''', deps='ndr samba-security NDR_SECURITY samba-util util_tdb ccan-hash') -bld.SAMBA3_LIBRARY('samba-cluster-support', - source=''' +if bld.CONFIG_GET("CTDB_CFLAGS"): + SAMBA_CLUSTER_SUPPORT_SOURCES=''' lib/cluster_support.c - lib/ctdb_dummy.c lib/dbwrap/dbwrap_ctdb.c lib/messages_ctdbd.c lib/ctdb_packet.c lib/ctdbd_conn.c lib/ctdb_conn.c torture/test_ctdbconn.c - ''', - deps=''' + ''' + SAMBA_CLUSTER_SUPPORT_DEPS=''' talloc tevent tdb - ''', + ''' +else: + SAMBA_CLUSTER_SUPPORT_SOURCES=''' + lib/cluster_support.c + lib/ctdb_dummy.c + ''' + SAMBA_CLUSTER_SUPPORT_DEPS=''' + talloc + tevent + ''' + +bld.SAMBA3_LIBRARY('samba-cluster-support', + source=SAMBA_CLUSTER_SUPPORT_SOURCES, + deps=SAMBA_CLUSTER_SUPPORT_DEPS, cflags=bld.CONFIG_GET("CTDB_CFLAGS"), allow_undefined_symbols=True, private_library=True) -- 1.7.9.5 >From 4661880a12cebf4bc8dfa5a65d7a95eca8e1027b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 21 Jan 2014 14:34:48 +0100 Subject: [PATCH 14/14] s3:build: remove global CLUSTER_SUPPORT define All ctdb specific code is isolated in samba-cluster-support.so now. Signed-off-by: Stefan Metzmacher --- source3/include/messages.h | 4 ---- source3/lib/cluster_support.c | 1 + source3/lib/dbwrap/dbwrap_open.c | 8 +------- source3/lib/messages.c | 7 ------- source3/lib/serverid.c | 4 ---- source3/lib/smbconf/smbconf_reg.c | 3 +-- source3/smbd/process.c | 7 ------- source3/smbd/server.c | 2 -- source3/wscript | 2 -- 9 files changed, 3 insertions(+), 35 deletions(-) diff --git a/source3/include/messages.h b/source3/include/messages.h index 5666911..d7a2853 100644 --- a/source3/include/messages.h +++ b/source3/include/messages.h @@ -60,11 +60,7 @@ #include "librpc/gen_ndr/server_id.h" -#ifdef CLUSTER_SUPPORT #define MSG_BROADCAST_PID_STR "0:0" -#else -#define MSG_BROADCAST_PID_STR "0" -#endif struct messaging_context; struct messaging_rec; diff --git a/source3/lib/cluster_support.c b/source3/lib/cluster_support.c index 4642367..d6605fd 100644 --- a/source3/lib/cluster_support.c +++ b/source3/lib/cluster_support.c @@ -22,6 +22,7 @@ #ifdef HAVE_CTDB_H #include +#define CLUSTER_SUPPORT 1 #endif #ifdef HAVE_CTDB_PROTOCOL_H diff --git a/source3/lib/dbwrap/dbwrap_open.c b/source3/lib/dbwrap/dbwrap_open.c index 021ebc3..81f20b0 100644 --- a/source3/lib/dbwrap/dbwrap_open.c +++ b/source3/lib/dbwrap/dbwrap_open.c @@ -30,7 +30,6 @@ bool db_is_local(const char *name) { -#ifdef CLUSTER_SUPPORT const char *sockname = lp_ctdbd_socket(); if (lp_clustering() && socket_exist(sockname)) { @@ -47,7 +46,7 @@ bool db_is_local(const char *name) return false; } } -#endif + return true; } @@ -62,9 +61,7 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx, uint64_t dbwrap_flags) { struct db_context *result = NULL; -#ifdef CLUSTER_SUPPORT const char *sockname; -#endif if (!DBWRAP_LOCK_ORDER_VALID(lock_order)) { errno = EINVAL; @@ -96,7 +93,6 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx, } } -#ifdef CLUSTER_SUPPORT sockname = lp_ctdbd_socket(); if (lp_clustering()) { @@ -131,8 +127,6 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx, } } -#endif - if (result == NULL) { struct loadparm_context *lp_ctx = loadparm_init_s3(mem_ctx, loadparm_s3_helpers()); result = dbwrap_local_open(mem_ctx, lp_ctx, name, hash_size, diff --git a/source3/lib/messages.c b/source3/lib/messages.c index 58f45d3..96b6b88 100644 --- a/source3/lib/messages.c +++ b/source3/lib/messages.c @@ -206,7 +206,6 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx, return NULL; } -#ifdef CLUSTER_SUPPORT if (lp_clustering()) { status = messaging_ctdbd_init(ctx, ctx, &ctx->remote); @@ -218,7 +217,6 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx, } } ctx->id.vnn = get_my_vnn(); -#endif messaging_register(ctx, NULL, MSG_PING, ping_message); @@ -254,7 +252,6 @@ NTSTATUS messaging_reinit(struct messaging_context *msg_ctx) return status; } -#ifdef CLUSTER_SUPPORT TALLOC_FREE(msg_ctx->remote); if (lp_clustering()) { @@ -268,8 +265,6 @@ NTSTATUS messaging_reinit(struct messaging_context *msg_ctx) } } -#endif - return NT_STATUS_OK; } @@ -365,13 +360,11 @@ NTSTATUS messaging_send(struct messaging_context *msg_ctx, return NT_STATUS_INVALID_PARAMETER_MIX; } -#ifdef CLUSTER_SUPPORT if (!procid_is_local(&server)) { return msg_ctx->remote->send_fn(msg_ctx, server, msg_type, data, msg_ctx->remote); } -#endif if (server_id_equal(&msg_ctx->id, &server)) { struct messaging_selfsend_state *state; diff --git a/source3/lib/serverid.c b/source3/lib/serverid.c index b69671e..5d59818 100644 --- a/source3/lib/serverid.c +++ b/source3/lib/serverid.c @@ -343,7 +343,6 @@ bool serverids_exist(const struct server_id *ids, int num_ids, bool *results) remote_num += 1; } -#ifdef CLUSTER_SUPPORT if (remote_num != 0 && ctdb_serverids_exist_supported(messaging_ctdbd_connection())) { @@ -388,7 +387,6 @@ bool serverids_exist(const struct server_id *ids, int num_ids, bool *results) results[idx] = todo_results[t]; } } -#endif if (remote_num != 0) { todo_num = 0; @@ -401,13 +399,11 @@ bool serverids_exist(const struct server_id *ids, int num_ids, bool *results) todo_num += 1; } -#ifdef CLUSTER_SUPPORT if (!ctdb_processes_exist(messaging_ctdbd_connection(), todo_ids, todo_num, todo_results)) { goto fail; } -#endif for (t=0; tnbt.got_session = false; sconn->smb1.negprot.max_recv = MIN(lp_max_xmit(),BUFFER_SIZE); diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 61ea17c..9d6a250 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -912,11 +912,9 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent, messaging_register(msg_ctx, NULL, ID_CACHE_KILL, smbd_parent_id_cache_kill); -#ifdef CLUSTER_SUPPORT if (lp_clustering()) { ctdbd_register_reconfigure(messaging_ctdbd_connection()); } -#endif #ifdef DEVELOPER messaging_register(msg_ctx, NULL, MSG_SMB_INJECT_FAULT, diff --git a/source3/wscript b/source3/wscript index eff1e2c..acb7af6 100644 --- a/source3/wscript +++ b/source3/wscript @@ -1705,7 +1705,6 @@ main() { conf.undefine('HAVE_CTDB_CHECK_CODE') if have_cluster_support: Logs.info("building with cluster support") - conf.DEFINE('CLUSTER_SUPPORT', 1); conf.env['CTDB_CFLAGS'] = CTDB_CFLAGS else: if Options.options.with_cluster_support == False: @@ -1716,7 +1715,6 @@ main() { else: Logs.info("building without cluster support: " + ctdb_broken) conf.env['CTDB_CFLAGS'] = '' - conf.undefine('CLUSTER_SUPPORT') conf.CHECK_CODE('__attribute__((destructor)) static void cleanup(void) { }', -- 1.7.9.5