summaryrefslogtreecommitdiff
path: root/ctdb
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2018-11-07 14:14:05 +0100
committerAndreas Schneider <asn@cryptomilk.org>2018-11-08 11:03:11 +0100
commit2d512b278e5905964c1294c587ba405678c3d10c (patch)
treea891cf0886d58e04d3ad2faadc5545c077865929 /ctdb
parent71ef09c1afdbf967b829cb66b33c3a5cb1c18ba0 (diff)
downloadsamba-2d512b278e5905964c1294c587ba405678c3d10c.tar.gz
debug: Use debuglevel_(get|set) function
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Thu Nov 8 11:03:11 CET 2018 on sn-devel-144
Diffstat (limited to 'ctdb')
-rw-r--r--ctdb/common/conf_tool.c6
-rw-r--r--ctdb/common/logging.c4
-rw-r--r--ctdb/common/path_tool.c2
-rw-r--r--ctdb/event/event_tool.c6
-rw-r--r--ctdb/server/ctdb_control.c11
-rw-r--r--ctdb/server/ctdb_recoverd.c2
-rw-r--r--ctdb/tests/src/ctdb_takeover_tests.c2
-rw-r--r--ctdb/tests/src/dummy_client.c2
-rw-r--r--ctdb/tests/src/test_options.c2
-rw-r--r--ctdb/tools/ctdb.c9
-rw-r--r--ctdb/tools/ctdb_killtcp.c9
11 files changed, 35 insertions, 20 deletions
diff --git a/ctdb/common/conf_tool.c b/ctdb/common/conf_tool.c
index e6020c504e6..8e0753eb787 100644
--- a/ctdb/common/conf_tool.c
+++ b/ctdb/common/conf_tool.c
@@ -276,6 +276,7 @@ int main(int argc, const char **argv)
TALLOC_CTX *mem_ctx;
struct conf_tool_context *ctx;
int ret, result;
+ int level;
bool ok;
mem_ctx = talloc_new(NULL);
@@ -297,10 +298,11 @@ int main(int argc, const char **argv)
}
setup_logging("ctdb-config", DEBUG_STDERR);
- ok = debug_level_parse(conf_data.debug, &DEBUGLEVEL);
+ ok = debug_level_parse(conf_data.debug, &level);
if (!ok) {
- DEBUGLEVEL = DEBUG_ERR;
+ level = DEBUG_ERR;
}
+ debuglevel_set(level);
ret = conf_tool_run(ctx, &result);
if (ret != 0) {
diff --git a/ctdb/common/logging.c b/ctdb/common/logging.c
index dc8c4f75058..aaa93216ef5 100644
--- a/ctdb/common/logging.c
+++ b/ctdb/common/logging.c
@@ -674,6 +674,7 @@ int logging_init(TALLOC_CTX *mem_ctx, const char *logging,
{
struct log_backend *backend = NULL;
char *option = NULL;
+ int level;
int ret;
setup_logging(app_name, DEBUG_STDERR);
@@ -681,9 +682,10 @@ int logging_init(TALLOC_CTX *mem_ctx, const char *logging,
if (debug_level == NULL) {
debug_level = getenv("CTDB_DEBUGLEVEL");
}
- if (! debug_level_parse(debug_level, &DEBUGLEVEL)) {
+ if (! debug_level_parse(debug_level, &level)) {
return EINVAL;
}
+ debuglevel_set(level);
if (logging == NULL) {
logging = getenv("CTDB_LOGGING");
diff --git a/ctdb/common/path_tool.c b/ctdb/common/path_tool.c
index 1c60b023c42..a19afa9b0c3 100644
--- a/ctdb/common/path_tool.c
+++ b/ctdb/common/path_tool.c
@@ -365,7 +365,7 @@ int main(int argc, const char **argv)
}
setup_logging("ctdb-path", DEBUG_STDERR);
- DEBUGLEVEL = DEBUG_ERR;
+ debuglevel_set(DEBUG_ERR);
ret = path_tool_run(ctx, &result);
if (ret != 0) {
diff --git a/ctdb/event/event_tool.c b/ctdb/event/event_tool.c
index f18deb8d5b1..8350f202cea 100644
--- a/ctdb/event/event_tool.c
+++ b/ctdb/event/event_tool.c
@@ -717,6 +717,7 @@ int main(int argc, const char **argv)
TALLOC_CTX *mem_ctx;
struct event_tool_context *ctx;
int ret, result = 0;
+ int level;
bool ok;
mem_ctx = talloc_new(NULL);
@@ -738,10 +739,11 @@ int main(int argc, const char **argv)
}
setup_logging("ctdb-event", DEBUG_STDERR);
- ok = debug_level_parse(event_data.debug, &DEBUGLEVEL);
+ ok = debug_level_parse(event_data.debug, &level);
if (!ok) {
- DEBUGLEVEL = DEBUG_ERR;
+ level = DEBUG_ERR;
}
+ debuglevel_set(level);
ret = event_tool_run(ctx, &result);
if (ret != 0) {
diff --git a/ctdb/server/ctdb_control.c b/ctdb/server/ctdb_control.c
index c260b924529..6c91e211660 100644
--- a/ctdb/server/ctdb_control.c
+++ b/ctdb/server/ctdb_control.c
@@ -100,6 +100,7 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
uint32_t opcode = c->opcode;
uint64_t srvid = c->srvid;
uint32_t client_id = c->client_id;
+ static int level = DEBUG_ERR;
switch (opcode) {
case CTDB_CONTROL_PROCESS_EXISTS: {
@@ -108,14 +109,20 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
}
case CTDB_CONTROL_SET_DEBUG: {
+ union {
+ uint8_t *ptr;
+ int32_t *level;
+ } debug;
CHECK_CONTROL_DATA_SIZE(sizeof(int32_t));
- DEBUGLEVEL = *(int32_t *)indata.dptr;
+ debug.ptr = indata.dptr;
+ debuglevel_set(*debug.level);
return 0;
}
case CTDB_CONTROL_GET_DEBUG: {
CHECK_CONTROL_DATA_SIZE(0);
- outdata->dptr = (uint8_t *)&(DEBUGLEVEL);
+ level = debuglevel_get();
+ outdata->dptr = (uint8_t *)&(level);
outdata->dsize = sizeof(DEBUGLEVEL);
return 0;
}
diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c
index 673c99c3d34..f000538bae2 100644
--- a/ctdb/server/ctdb_recoverd.c
+++ b/ctdb/server/ctdb_recoverd.c
@@ -2637,7 +2637,7 @@ static void main_loop(struct ctdb_context *ctdb, struct ctdb_recoverd *rec,
DEBUG(DEBUG_ERR, (__location__ " Failed to read debuglevel from parent\n"));
return;
}
- DEBUGLEVEL = debug_level;
+ debuglevel_set(debug_level);
/* get relevant tunables */
ret = ctdb_ctrl_get_all_tunables(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE, &ctdb->tunable);
diff --git a/ctdb/tests/src/ctdb_takeover_tests.c b/ctdb/tests/src/ctdb_takeover_tests.c
index e9958ce205a..cc6b4416dd9 100644
--- a/ctdb/tests/src/ctdb_takeover_tests.c
+++ b/ctdb/tests/src/ctdb_takeover_tests.c
@@ -257,7 +257,7 @@ int main(int argc, const char *argv[])
if (! debug_level_parse(debuglevelstr, &loglevel)) {
loglevel = DEBUG_DEBUG;
}
- DEBUGLEVEL = loglevel;
+ debuglevel_set(loglevel);
if (argc < 2) {
usage();
diff --git a/ctdb/tests/src/dummy_client.c b/ctdb/tests/src/dummy_client.c
index 22ba40f6e3b..13e069180a3 100644
--- a/ctdb/tests/src/dummy_client.c
+++ b/ctdb/tests/src/dummy_client.c
@@ -104,7 +104,7 @@ int main(int argc, const char *argv[])
}
setup_logging("dummy_client", DEBUG_STDERR);
- DEBUGLEVEL = log_level;
+ debuglevel_set(log_level);
if (options.sockpath == NULL) {
options.sockpath = path_socket(mem_ctx, "ctdbd");
diff --git a/ctdb/tests/src/test_options.c b/ctdb/tests/src/test_options.c
index cfce51aeeb6..ba9c4961771 100644
--- a/ctdb/tests/src/test_options.c
+++ b/ctdb/tests/src/test_options.c
@@ -98,7 +98,7 @@ static bool verify_options_basic(struct test_options *opts)
return false;
}
- DEBUGLEVEL = log_level;
+ debuglevel_set(log_level);
return true;
}
diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c
index 8fa1ce63203..f96167f9366 100644
--- a/ctdb/tools/ctdb.c
+++ b/ctdb/tools/ctdb.c
@@ -6188,6 +6188,7 @@ int main(int argc, const char *argv[])
int extra_argc;
const struct ctdb_cmd *cmd;
int loglevel;
+ bool ok;
int ret;
setlinebuf(stdout);
@@ -6246,11 +6247,11 @@ int main(int argc, const char *argv[])
/* Enable logging */
setup_logging("ctdb", DEBUG_STDERR);
- if (debug_level_parse(options.debuglevelstr, &loglevel)) {
- DEBUGLEVEL = loglevel;
- } else {
- DEBUGLEVEL = DEBUG_ERR;
+ ok = debug_level_parse(options.debuglevelstr, &loglevel);
+ if (!ok) {
+ loglevel = DEBUG_ERR;
}
+ debuglevel_set(loglevel);
signal(SIGALRM, alarm_handler);
alarm(options.maxruntime);
diff --git a/ctdb/tools/ctdb_killtcp.c b/ctdb/tools/ctdb_killtcp.c
index 8537a579670..fc443bd08e2 100644
--- a/ctdb/tools/ctdb_killtcp.c
+++ b/ctdb/tools/ctdb_killtcp.c
@@ -330,16 +330,17 @@ int main(int argc, char **argv)
struct tevent_req *req;
int debug_level;
bool status;
+ bool ok;
int ret;
/* Set the debug level */
t = getenv("CTDB_DEBUGLEVEL");
if (t != NULL) {
- if (debug_level_parse(t, &debug_level)) {
- DEBUGLEVEL = debug_level;
- } else {
- DEBUGLEVEL = DEBUG_ERR;
+ ok = debug_level_parse(t, &debug_level);
+ if (!ok) {
+ debug_level = DEBUG_ERR;
}
+ debuglevel_set(debug_level);
}
if (argc != 2 && argc != 4) {