summaryrefslogtreecommitdiff
path: root/source/utils
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2009-03-04 21:46:32 +0100
committerKarolin Seeger <kseeger@samba.org>2009-03-27 14:15:40 +0100
commit9889720d204e27cceb2ef9d26a3647e0bc3b480a (patch)
treee929ec2194453ad4672d1e385bd4edf0e78ebab2 /source/utils
parent8f6377ce55d4f2170d2fe1aaf13437f417f2183f (diff)
downloadsamba-9889720d204e27cceb2ef9d26a3647e0bc3b480a.tar.gz
s3:net conf: reduce memory usage of "net conf import".
"net conf import" was wrapped in one big transaction. This lead to MAX_TALLOC_SIZE being exceeded at roughly 1500 shares. This patch resolves that problem by limiting the top level transactions in "net conf import" to 100 shares. Michael Signed-off-by: Michael Adam <obnox@samba.org> (cherry picked from commit 026b72903c852e46012ac60d9d42b14c6860a159)
Diffstat (limited to 'source/utils')
-rw-r--r--source/utils/net_conf.c39
1 files changed, 33 insertions, 6 deletions
diff --git a/source/utils/net_conf.c b/source/utils/net_conf.c
index 5847dc71974..9fc6e73d2dc 100644
--- a/source/utils/net_conf.c
+++ b/source/utils/net_conf.c
@@ -331,12 +331,6 @@ static int net_conf_import(struct net_context *c, struct smbconf_ctx *conf_ctx,
"would import the following configuration:\n\n");
}
- werr = smbconf_transaction_start(conf_ctx);
- if (!W_ERROR_IS_OK(werr)) {
- d_printf("error starting transaction: %s\n", win_errstr(werr));
- goto done;
- }
-
if (servicename != NULL) {
struct smbconf_service *service = NULL;
@@ -366,12 +360,45 @@ static int net_conf_import(struct net_context *c, struct smbconf_ctx *conf_ctx,
goto cancel;
}
}
+
+ /*
+ * Wrap the importing of shares into a transaction,
+ * but only 100 at a time, in order to serve memory.
+ * The allocated memory accumulates across the actions
+ * within the transaction, and for me, some 1500
+ * imported shares, the MAX_TALLOC_SIZE of 256 MB
+ * was exceeded.
+ */
+ werr = smbconf_transaction_start(conf_ctx);
+ if (!W_ERROR_IS_OK(werr)) {
+ d_printf("error starting transaction: %s\n",
+ win_errstr(werr));
+ goto done;
+ }
+
for (sidx = 0; sidx < num_shares; sidx++) {
werr = import_process_service(c, conf_ctx,
services[sidx]);
if (!W_ERROR_IS_OK(werr)) {
goto cancel;
}
+
+ if (sidx % 100) {
+ continue;
+ }
+
+ werr = smbconf_transaction_commit(conf_ctx);
+ if (!W_ERROR_IS_OK(werr)) {
+ d_printf("error committing transaction: %s\n",
+ win_errstr(werr));
+ goto done;
+ }
+ werr = smbconf_transaction_start(conf_ctx);
+ if (!W_ERROR_IS_OK(werr)) {
+ d_printf("error starting transaction: %s\n",
+ win_errstr(werr));
+ goto done;
+ }
}
}