From 64acc4740993ec76124a05b7c64ab8910d66e50f Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Mon, 14 May 2018 16:52:58 +1000 Subject: [PATCH 1/4] socket_wrapper: Add missing dependency on tirpc Signed-off-by: Amitay Isaacs Reviewed-by: Andreas Schneider Autobuild-User(master): Amitay Isaacs Autobuild-Date(master): Tue May 22 13:57:07 CEST 2018 on sn-devel-144 (cherry picked from commit 7049b2153b08152f03a0fcbb1817b430fe0a8451) --- third_party/socket_wrapper/wscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/socket_wrapper/wscript b/third_party/socket_wrapper/wscript index 1693b44eece..86c9b3b59ed 100644 --- a/third_party/socket_wrapper/wscript +++ b/third_party/socket_wrapper/wscript @@ -109,6 +109,6 @@ def build(bld): # breaks preloading! bld.SAMBA_LIBRARY('socket_wrapper', source='socket_wrapper.c', - deps='dl pthread', + deps='dl pthread tirpc', install=False, realname='libsocket-wrapper.so') -- 2.17.1 From 337763619f1483d2e2610ebc049a636beeb40a00 Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Thu, 1 Mar 2018 12:32:26 +1100 Subject: [PATCH 2/4] ctdb-pmda: Use modified API in pcp library 4.0 Support backward compatibility by checking for __pmID_int type, which was previously in . In the new version, this type is not defined anymore and there is no need to include . Signed-off-by: Amitay Isaacs Reviewed-by: Martin Schwenke Autobuild-User(master): Martin Schwenke Autobuild-Date(master): Fri Mar 2 00:38:52 CET 2018 on sn-devel-144 (cherry picked from commit 426e4a5a20cff73a80d80b46f15826deac3f934f) --- ctdb/utils/pmda/pmda_ctdb.c | 30 +++++++++++++++++++++--------- ctdb/wscript | 1 + 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/ctdb/utils/pmda/pmda_ctdb.c b/ctdb/utils/pmda/pmda_ctdb.c index 41eaf93fb18..45ec5f19821 100644 --- a/ctdb/utils/pmda/pmda_ctdb.c +++ b/ctdb/utils/pmda/pmda_ctdb.c @@ -33,9 +33,17 @@ #include "client/client_sync.h" #include -#include #include +#ifdef HAVE___PMID_INT +#include + +#define pmID_cluster(id) id->cluster +#define pmID_item(id) id->item +#define pmGetProgname() pmProgname +#define pmSetProgname(a) __pmSetProgname(a) +#endif + #include "domain.h" /* @@ -386,7 +394,11 @@ static int pmda_ctdb_fetch_cb(pmdaMetric *mdesc, unsigned int inst, pmAtomValue *atom) { int ret; +#ifdef HAVE___PMID_INT __pmID_int *id = (__pmID_int *)&(mdesc->m_desc.pmid); +#else + pmID id = *(pmID *)&(mdesc->m_desc.pmid); +#endif if (inst != PM_IN_NULL) { return PM_ERR_INST; @@ -399,27 +411,27 @@ pmda_ctdb_fetch_cb(pmdaMetric *mdesc, unsigned int inst, pmAtomValue *atom) } - switch (id->cluster) { + switch (pmID_cluster(id)) { case 0: - ret = fill_base(id->item, atom); + ret = fill_base(pmID_item(id), atom); if (ret) { goto err_out; } break; case 1: - ret = fill_node(id->item, atom); + ret = fill_node(pmID_item(id), atom); if (ret) { goto err_out; } break; case 2: - ret = fill_client(id->item, atom); + ret = fill_client(pmID_item(id), atom); if (ret) { goto err_out; } break; case 3: - ret = fill_timeout(id->item, atom); + ret = fill_timeout(pmID_item(id), atom); if (ret) { goto err_out; } @@ -502,7 +514,7 @@ helpfile(void) static void usage(void) { - fprintf(stderr, "Usage: %s [options]\n\n", pmProgname); + fprintf(stderr, "Usage: %s [options]\n\n", pmGetProgname()); fputs("Options:\n" " -d domain use domain (numeric) for metrics domain of PMDA\n" " -l logfile write log into logfile rather than using default log name\n" @@ -524,9 +536,9 @@ main(int argc, char **argv) char log_file[] = "pmda_ctdb.log"; pmdaInterface dispatch; - __pmSetProgname(argv[0]); + pmSetProgname(argv[0]); - pmdaDaemon(&dispatch, PMDA_INTERFACE_2, pmProgname, CTDB, + pmdaDaemon(&dispatch, PMDA_INTERFACE_2, argv[0], CTDB, log_file, helpfile()); if (pmdaGetOpt(argc, argv, "d:i:l:pu:?", &dispatch, &err) != EOF) { diff --git a/ctdb/wscript b/ctdb/wscript index 059ce3d43d8..6a039991a8f 100644 --- a/ctdb/wscript +++ b/ctdb/wscript @@ -175,6 +175,7 @@ def configure(conf): if not conf.CHECK_FUNCS_IN('pmdaDaemon', 'pcp_pmda'): pmda_support = False if pmda_support: + conf.CHECK_TYPE_IN('__pmID_int', 'pcp/pmapi.h pcp/impl.h') have_pmda = True else: Logs.error("PMDA support not available") -- 2.17.1 From 55affa23f933cda8c94e6e0530b98603707feb1a Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Thu, 21 Jun 2018 20:00:41 +1000 Subject: [PATCH 3/4] ctdb-tests: Avoid segfault by initializing logging Setting DEBUGLEVEL before calling debug_init() causes segmentation violation with gcc8. DEBUGLEVEL_CLASS is statically initialized to debug_class_list_initial which is defined as const. Only after debug_init() is called, DEBUGLEVEL_CLASS becomes a talloc'd array. So before modifying DEBUGLEVEL, ensure debug_init() is called via setup_logging(). (debug_init is a static function.) Signed-off-by: Amitay Isaacs Reviewed-by: Martin Schwenke (cherry picked from commit af697008531bd74546656841dd3a1ed92522fc57) --- ctdb/tests/src/fetch_loop.c | 3 +++ ctdb/tests/src/fetch_loop_key.c | 3 +++ ctdb/tests/src/fetch_readonly.c | 3 +++ ctdb/tests/src/fetch_readonly_loop.c | 3 +++ ctdb/tests/src/fetch_ring.c | 3 +++ ctdb/tests/src/g_lock_loop.c | 4 ++-- ctdb/tests/src/message_ring.c | 3 +++ ctdb/tests/src/transaction_loop.c | 3 +++ ctdb/tests/src/tunnel_test.c | 3 +++ ctdb/tests/src/update_record.c | 3 +++ ctdb/tests/src/update_record_persistent.c | 3 +++ ctdb/wscript | 2 +- 12 files changed, 33 insertions(+), 3 deletions(-) diff --git a/ctdb/tests/src/fetch_loop.c b/ctdb/tests/src/fetch_loop.c index 6767f71207a..0e1d9dadfba 100644 --- a/ctdb/tests/src/fetch_loop.c +++ b/ctdb/tests/src/fetch_loop.c @@ -20,6 +20,7 @@ #include "replace.h" #include "system/network.h" +#include "lib/util/debug.h" #include "lib/util/tevent_unix.h" #include "client/client.h" @@ -230,6 +231,8 @@ int main(int argc, const char *argv[]) int ret; bool status; + setup_logging("fetch_loop", DEBUG_STDERR); + status = process_options_basic(argc, argv, &opts); if (! status) { exit(1); diff --git a/ctdb/tests/src/fetch_loop_key.c b/ctdb/tests/src/fetch_loop_key.c index b13784224f5..3f41ca75954 100644 --- a/ctdb/tests/src/fetch_loop_key.c +++ b/ctdb/tests/src/fetch_loop_key.c @@ -20,6 +20,7 @@ #include "replace.h" #include "system/network.h" +#include "lib/util/debug.h" #include "lib/util/tevent_unix.h" #include "client/client.h" @@ -155,6 +156,8 @@ int main(int argc, const char *argv[]) int ret; bool status; + setup_logging("fetch_loop_key", DEBUG_STDERR); + status = process_options_database(argc, argv, &opts); if (! status) { exit(1); diff --git a/ctdb/tests/src/fetch_readonly.c b/ctdb/tests/src/fetch_readonly.c index 5d2972a3f09..ff126bdf5ae 100644 --- a/ctdb/tests/src/fetch_readonly.c +++ b/ctdb/tests/src/fetch_readonly.c @@ -20,6 +20,7 @@ #include "replace.h" #include "system/network.h" +#include "lib/util/debug.h" #include "lib/util/tevent_unix.h" #include "client/client.h" @@ -107,6 +108,8 @@ int main(int argc, const char *argv[]) int ret; bool status; + setup_logging("fetch_readonly", DEBUG_STDERR); + status = process_options_database(argc, argv, &opts); if (! status) { exit(1); diff --git a/ctdb/tests/src/fetch_readonly_loop.c b/ctdb/tests/src/fetch_readonly_loop.c index 9d5d22e7534..08cf4766659 100644 --- a/ctdb/tests/src/fetch_readonly_loop.c +++ b/ctdb/tests/src/fetch_readonly_loop.c @@ -20,6 +20,7 @@ #include "replace.h" #include "system/network.h" +#include "lib/util/debug.h" #include "lib/util/tevent_unix.h" #include "client/client.h" @@ -214,6 +215,8 @@ int main(int argc, const char *argv[]) int ret; bool status; + setup_logging("fetch_readonly_loop", DEBUG_STDERR); + status = process_options_basic(argc, argv, &opts); if (! status) { exit(1); diff --git a/ctdb/tests/src/fetch_ring.c b/ctdb/tests/src/fetch_ring.c index eb64648139e..f746e789511 100644 --- a/ctdb/tests/src/fetch_ring.c +++ b/ctdb/tests/src/fetch_ring.c @@ -20,6 +20,7 @@ #include "replace.h" #include "system/network.h" +#include "lib/util/debug.h" #include "lib/util/time.h" #include "lib/util/tevent_unix.h" @@ -331,6 +332,8 @@ int main(int argc, const char *argv[]) int ret; bool status; + setup_logging("fetch_ring", DEBUG_STDERR); + status = process_options_basic(argc, argv, &opts); if (! status) { exit(1); diff --git a/ctdb/tests/src/g_lock_loop.c b/ctdb/tests/src/g_lock_loop.c index f29d0f1235a..3b84241ff20 100644 --- a/ctdb/tests/src/g_lock_loop.c +++ b/ctdb/tests/src/g_lock_loop.c @@ -213,6 +213,8 @@ int main(int argc, const char *argv[]) int ret; bool status; + setup_logging("glock_loop", DEBUG_STDERR); + status = process_options_basic(argc, argv, &opts); if (! status) { exit(1); @@ -230,8 +232,6 @@ int main(int argc, const char *argv[]) exit(1); } - setup_logging("glock_loop", DEBUG_STDERR); - ret = ctdb_client_init(mem_ctx, ev, opts->socket, &client); if (ret != 0) { fprintf(stderr, "Failed to initialize client, ret=%d\n", ret); diff --git a/ctdb/tests/src/message_ring.c b/ctdb/tests/src/message_ring.c index dabae65ff86..d1fcee4e358 100644 --- a/ctdb/tests/src/message_ring.c +++ b/ctdb/tests/src/message_ring.c @@ -20,6 +20,7 @@ #include "replace.h" #include "system/network.h" +#include "lib/util/debug.h" #include "lib/util/time.h" #include "lib/util/tevent_unix.h" @@ -317,6 +318,8 @@ int main(int argc, const char *argv[]) int ret; bool status; + setup_logging("message_ring", DEBUG_STDERR); + status = process_options_basic(argc, argv, &opts); if (! status) { exit(1); diff --git a/ctdb/tests/src/transaction_loop.c b/ctdb/tests/src/transaction_loop.c index 66237512c87..a423d6817fd 100644 --- a/ctdb/tests/src/transaction_loop.c +++ b/ctdb/tests/src/transaction_loop.c @@ -20,6 +20,7 @@ #include "replace.h" #include "system/network.h" +#include "lib/util/debug.h" #include "lib/util/tevent_unix.h" #include "client/client.h" @@ -342,6 +343,8 @@ int main(int argc, const char *argv[]) int ret; bool status; + setup_logging("transaction_loop", DEBUG_STDERR); + status = process_options_database(argc, argv, &opts); if (! status) { exit(1); diff --git a/ctdb/tests/src/tunnel_test.c b/ctdb/tests/src/tunnel_test.c index 53ad83057ed..a6d44ba19c3 100644 --- a/ctdb/tests/src/tunnel_test.c +++ b/ctdb/tests/src/tunnel_test.c @@ -20,6 +20,7 @@ #include "replace.h" #include "system/network.h" +#include "lib/util/debug.h" #include "lib/util/tevent_unix.h" #include "protocol/protocol_private.h" @@ -429,6 +430,8 @@ int main(int argc, const char *argv[]) int ret; bool status; + setup_logging("tunnel_test", DEBUG_STDERR); + status = process_options_basic(argc, argv, &opts); if (! status) { exit(1); diff --git a/ctdb/tests/src/update_record.c b/ctdb/tests/src/update_record.c index 78291d7dc8e..11b6050ad81 100644 --- a/ctdb/tests/src/update_record.c +++ b/ctdb/tests/src/update_record.c @@ -20,6 +20,7 @@ #include "replace.h" #include "system/network.h" +#include "lib/util/debug.h" #include "lib/util/tevent_unix.h" #include "protocol/protocol_api.h" @@ -177,6 +178,8 @@ int main(int argc, const char *argv[]) int ret; bool status; + setup_logging("update_record", DEBUG_STDERR); + status = process_options_database(argc, argv, &opts); if (! status) { exit(1); diff --git a/ctdb/tests/src/update_record_persistent.c b/ctdb/tests/src/update_record_persistent.c index 9323e3743c2..2d6d21e25cf 100644 --- a/ctdb/tests/src/update_record_persistent.c +++ b/ctdb/tests/src/update_record_persistent.c @@ -20,6 +20,7 @@ #include "replace.h" #include "system/network.h" +#include "lib/util/debug.h" #include "lib/util/tevent_unix.h" #include "protocol/protocol_api.h" @@ -153,6 +154,8 @@ int main(int argc, const char *argv[]) int ret; bool status; + setup_logging("update_record_persistene", DEBUG_STDERR); + status = process_options_database(argc, argv, &opts); if (! status) { exit(1); diff --git a/ctdb/wscript b/ctdb/wscript index 6a039991a8f..1ca90a4d5b0 100644 --- a/ctdb/wscript +++ b/ctdb/wscript @@ -816,7 +816,7 @@ def build(bld): source=bld.SUBDIR('tests/src', 'cluster_wait.c test_options.c'), includes='include', - deps='replace popt talloc tevent tdb') + deps='samba-util replace popt talloc tevent tdb') # Test binaries ctdb_tests = [ -- 2.17.1 From fa1e955ba32da728070eafb9d8ea8738c946f6b2 Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Thu, 5 Jul 2018 13:40:33 +1000 Subject: [PATCH 4/4] ctdb-tests: Avoid segfault by initializing logging This is in addition to af697008531. Signed-off-by: Amitay Isaacs Reviewed-by: Martin Schwenke Autobuild-User(master): Martin Schwenke Autobuild-Date(master): Thu Jul 5 15:22:16 CEST 2018 on sn-devel-144 (cherry picked from commit a30ac853ff9bca023c53ad98775eabb23156c566) --- ctdb/tests/src/ctdb_takeover_tests.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ctdb/tests/src/ctdb_takeover_tests.c b/ctdb/tests/src/ctdb_takeover_tests.c index 951ae5201ef..ecbc1fd2fba 100644 --- a/ctdb/tests/src/ctdb_takeover_tests.c +++ b/ctdb/tests/src/ctdb_takeover_tests.c @@ -254,6 +254,8 @@ int main(int argc, const char *argv[]) int loglevel; const char *debuglevelstr = getenv("CTDB_TEST_LOGLEVEL"); + setup_logging("ctdb_takeover_tests", DEBUG_STDERR); + if (! debug_level_parse(debuglevelstr, &loglevel)) { loglevel = DEBUG_DEBUG; } -- 2.17.1