2 samba -- Unix SMB/CIFS implementation.
3 Copyright (C) 2001, 2002 by Martin Pool
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "lib/util/talloc_report.h"
24 #endif /* HAVE_MALLINFO */
27 * Prepare memory allocation report based on mallinfo()
29 static char *get_mallinfo_report(void *mem_ctx)
36 report = talloc_asprintf(mem_ctx,
58 #endif /* HAVE_MALLINFO */
63 * Respond to a POOL_USAGE message by sending back string form of memory
66 static void msg_pool_usage(struct messaging_context *msg_ctx,
77 SMB_ASSERT(msg_type == MSG_REQ_POOL_USAGE);
79 DEBUG(2,("Got POOL_USAGE\n"));
81 report = talloc_report_str(msg_ctx, NULL);
83 iov[iov_size].iov_base = report;
84 iov[iov_size].iov_len = talloc_get_size(report) - 1;
88 mreport = get_mallinfo_report(msg_ctx);
89 if (mreport != NULL) {
90 iov[iov_size].iov_base = mreport;
91 iov[iov_size].iov_len = talloc_get_size(mreport) - 1;
96 messaging_send_iov(msg_ctx,
106 TALLOC_FREE(mreport);
110 * Register handler for MSG_REQ_POOL_USAGE
112 void register_msg_pool_usage(struct messaging_context *msg_ctx)
114 messaging_register(msg_ctx, NULL, MSG_REQ_POOL_USAGE, msg_pool_usage);
115 DEBUG(2, ("Registered MSG_REQ_POOL_USAGE\n"));