summaryrefslogtreecommitdiff
path: root/source3/utils/net_conf.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2009-03-05 12:24:35 +1100
committerAndrew Bartlett <abartlet@samba.org>2009-03-05 12:24:35 +1100
commit41760c18bdab20d526d32568531bdf7c88272879 (patch)
treeb2f421919501a3061afe40f0cb0980f86f448ea8 /source3/utils/net_conf.c
parent8249383efb2037bb234dd040ebe151329cc4feb9 (diff)
parentc8ea9d1f13096cd7f51e5972915a61ca65b56ac3 (diff)
downloadsamba-41760c18bdab20d526d32568531bdf7c88272879.tar.gz
samba-41760c18bdab20d526d32568531bdf7c88272879.tar.bz2
samba-41760c18bdab20d526d32568531bdf7c88272879.zip
Merge branch 'master' of ssh://git.samba.org/data/git/samba into wspp-schema
Diffstat (limited to 'source3/utils/net_conf.c')
-rw-r--r--source3/utils/net_conf.c58
1 files changed, 53 insertions, 5 deletions
diff --git a/source3/utils/net_conf.c b/source3/utils/net_conf.c
index 0c2cd24fb2..38a2553e53 100644
--- a/source3/utils/net_conf.c
+++ b/source3/utils/net_conf.c
@@ -338,11 +338,11 @@ static int net_conf_import(struct net_context *c, struct smbconf_ctx *conf_ctx,
servicename,
&service);
if (!W_ERROR_IS_OK(werr)) {
- goto done;
+ goto cancel;
}
werr = import_process_service(c, conf_ctx, service);
if (!W_ERROR_IS_OK(werr)) {
- goto done;
+ goto cancel;
}
} else {
struct smbconf_service **services = NULL;
@@ -352,24 +352,72 @@ static int net_conf_import(struct net_context *c, struct smbconf_ctx *conf_ctx,
&num_shares,
&services);
if (!W_ERROR_IS_OK(werr)) {
- goto done;
+ goto cancel;
}
if (!c->opt_testmode) {
werr = smbconf_drop(conf_ctx);
if (!W_ERROR_IS_OK(werr)) {
- goto done;
+ 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;
}
}
}
- ret = 0;
+ werr = smbconf_transaction_commit(conf_ctx);
+ if (!W_ERROR_IS_OK(werr)) {
+ d_printf("error committing transaction: %s\n",
+ win_errstr(werr));
+ } else {
+ ret = 0;
+ }
+
+ goto done;
+
+cancel:
+ werr = smbconf_transaction_cancel(conf_ctx);
+ if (!W_ERROR_IS_OK(werr)) {
+ d_printf("error cancelling transaction: %s\n",
+ win_errstr(werr));
+ }
done:
TALLOC_FREE(mem_ctx);