diff options
-rw-r--r-- | ctdb/server/ctdb_control.c | 40 | ||||
-rwxr-xr-x | ctdb/wscript | 4 | ||||
-rwxr-xr-x | lib/util/wscript_build | 14 |
3 files changed, 24 insertions, 34 deletions
diff --git a/ctdb/server/ctdb_control.c b/ctdb/server/ctdb_control.c index 59b7d098671..ee69270c784 100644 --- a/ctdb/server/ctdb_control.c +++ b/ctdb/server/ctdb_control.c @@ -24,6 +24,7 @@ #include "../include/ctdb_private.h" #include "lib/util/dlinklist.h" #include "lib/tdb_wrap/tdb_wrap.h" +#include "lib/util/talloc_report.h" struct ctdb_control_state { @@ -40,34 +41,23 @@ struct ctdb_control_state { */ int32_t ctdb_dump_memory(struct ctdb_context *ctdb, TDB_DATA *outdata) { - /* dump to a file, then send the file as a blob */ - FILE *f; - long fsize; - f = tmpfile(); - if (f == NULL) { - DEBUG(DEBUG_ERR,(__location__ " Unable to open tmpfile - %s\n", strerror(errno))); - return -1; - } - talloc_report_full(NULL, f); - fsize = ftell(f); - if (fsize == -1) { - DEBUG(DEBUG_ERR, (__location__ " Unable to get file size - %s\n", - strerror(errno))); - fclose(f); + char *report; + size_t reportlen; + + report = talloc_report_str(outdata, NULL); + if (report == NULL) { + DEBUG(DEBUG_ERR, + (__location__ " talloc_report_str failed\n")); return -1; } - rewind(f); - outdata->dptr = talloc_size(outdata, fsize); - if (outdata->dptr == NULL) { - fclose(f); - CTDB_NO_MEMORY(ctdb, outdata->dptr); - } - outdata->dsize = fread(outdata->dptr, 1, fsize, f); - fclose(f); - if (outdata->dsize != fsize) { - DEBUG(DEBUG_ERR,(__location__ " Unable to read tmpfile\n")); - return -1; + reportlen = talloc_get_size(report); + + if (reportlen > 0) { + reportlen -= 1; /* strip trailing zero */ } + + outdata->dptr = (uint8_t *)report; + outdata->dsize = reportlen; return 0; } diff --git a/ctdb/wscript b/ctdb/wscript index 06f86a31916..8aa037409e0 100755 --- a/ctdb/wscript +++ b/ctdb/wscript @@ -348,7 +348,7 @@ def build(bld): include/ctdb_private.h include/ctdb_protocol.h include/ctdb_typesafe_cb.h''', - deps='replace popt talloc tevent tdb') + deps='replace popt talloc tevent tdb talloc_report') bld.SAMBA_BINARY('ctdbd', source='', @@ -547,7 +547,7 @@ def build(bld): bld.SAMBA_BINARY('ctdb_takeover_tests', source='tests/src/ctdb_takeover_tests.c', deps='''replace popt tdb tevent talloc ctdb-system - samba-util tdb-wrap''' + + samba-util tdb-wrap talloc_report''' + ib_deps, includes='include include/internal', install_path='${CTDB_TEST_LIBDIR}') diff --git a/lib/util/wscript_build b/lib/util/wscript_build index 9663bb0fd98..e5c1a97d151 100755 --- a/lib/util/wscript_build +++ b/lib/util/wscript_build @@ -54,6 +54,13 @@ bld.SAMBA_LIBRARY('socket-blocking', local_include=False, private_library=True) +bld.SAMBA_LIBRARY('talloc_report', + source='talloc_report.c', + local_include=False, + public_deps='talloc', + private_library=True + ) + bld.SAMBA_SUBSYSTEM('samba-util-core', source='''xfile.c data_blob.c util_file.c time.c signal.c util.c idtree.c fault.c @@ -119,13 +126,6 @@ if not bld.env.SAMBA_UTIL_CORE_ONLY: private_library=True ) - bld.SAMBA_LIBRARY('talloc_report', - source='talloc_report.c', - local_include=False, - public_deps='talloc', - private_library=True - ) - bld.SAMBA_LIBRARY('tevent-util', source='tevent_unix.c tevent_ntstatus.c tevent_werror.c', local_include=False, |