summaryrefslogtreecommitdiff
path: root/source3/lib/tallocmsg.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib/tallocmsg.c')
-rw-r--r--source3/lib/tallocmsg.c50
1 files changed, 49 insertions, 1 deletions
diff --git a/source3/lib/tallocmsg.c b/source3/lib/tallocmsg.c
index b5ab21c5661..9be1bf58a3c 100644
--- a/source3/lib/tallocmsg.c
+++ b/source3/lib/tallocmsg.c
@@ -19,7 +19,46 @@
#include "includes.h"
#include "messages.h"
#include "lib/util/talloc_report.h"
+#ifdef HAVE_MALLINFO
+#include <malloc.h>
+#endif /* HAVE_MALLINFO */
+ /**
+ * Prepare memory allocation report based on mallinfo()
+ **/
+static char *get_mallinfo_report(void *mem_ctx)
+{
+ char *report = NULL;
+#ifdef HAVE_MALLINFO
+ struct mallinfo mi;
+
+ mi = mallinfo();
+ report = talloc_asprintf(mem_ctx,
+ "mallinfo:\n"
+ " arena: %d\n"
+ " ordblks: %d\n"
+ " smblks: %d\n"
+ " hblks: %d\n"
+ " hblkhd: %d\n"
+ " usmblks: %d\n"
+ " fsmblks: %d\n"
+ " uordblks: %d\n"
+ " fordblks: %d\n"
+ " keepcost: %d\n",
+ mi.arena,
+ mi.ordblks,
+ mi.smblks,
+ mi.hblks,
+ mi.hblkhd,
+ mi.usmblks,
+ mi.fsmblks,
+ mi.uordblks,
+ mi.fordblks,
+ mi.keepcost);
+#endif /* HAVE_MALLINFO */
+
+ return report;
+}
/**
* Respond to a POOL_USAGE message by sending back string form of memory
* usage stats.
@@ -31,8 +70,9 @@ static void msg_pool_usage(struct messaging_context *msg_ctx,
DATA_BLOB *data)
{
char *report = NULL;
+ char *mreport = NULL;
int iov_size = 0;
- struct iovec iov[1];
+ struct iovec iov[2];
SMB_ASSERT(msg_type == MSG_REQ_POOL_USAGE);
@@ -45,6 +85,13 @@ static void msg_pool_usage(struct messaging_context *msg_ctx,
iov_size++;
}
+ mreport = get_mallinfo_report(msg_ctx);
+ if (mreport != NULL) {
+ iov[iov_size].iov_base = mreport;
+ iov[iov_size].iov_len = talloc_get_size(mreport) - 1;
+ iov_size++;
+ }
+
if (iov_size) {
messaging_send_iov(msg_ctx,
src,
@@ -56,6 +103,7 @@ static void msg_pool_usage(struct messaging_context *msg_ctx,
}
TALLOC_FREE(report);
+ TALLOC_FREE(mreport);
}
/**