#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 {
*/
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;
}
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='',
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}')
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
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,