[SCM] Samba Shared Repository - branch master updated

Michael Adam obnox at samba.org
Fri Feb 12 15:15:39 MST 2010


The branch, master has been updated
       via  09f3ed1... s3:make "net conf addshare" atomic by wrapping all writes in one transaction
      from  83fffbe... s3:g_lock: remove a nested event loop, replacing the inner loop by select

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 09f3ed102472304d6b4446a6fab9cf6f05c9176a
Author: Michael Adam <obnox at samba.org>
Date:   Fri Jan 29 15:04:25 2010 +0100

    s3:make "net conf addshare" atomic by wrapping all writes in one transaction
    
    Michael

-----------------------------------------------------------------------

Summary of changes:
 source3/utils/net_conf.c |   42 ++++++++++++++++++++++++++++++++++++------
 1 files changed, 36 insertions(+), 6 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/utils/net_conf.c b/source3/utils/net_conf.c
index e6e8e52..67e3c85 100644
--- a/source3/utils/net_conf.c
+++ b/source3/utils/net_conf.c
@@ -691,6 +691,17 @@ static int net_conf_addshare(struct net_context *c,
 	}
 
 	/*
+	 * start a transaction
+	 */
+
+	werr = smbconf_transaction_start(conf_ctx);
+	if (!W_ERROR_IS_OK(werr)) {
+		d_printf("error starting transaction: %s\n",
+			 win_errstr(werr));
+		goto done;
+	}
+
+	/*
 	 * create the share
 	 */
 
@@ -698,7 +709,7 @@ static int net_conf_addshare(struct net_context *c,
 	if (!W_ERROR_IS_OK(werr)) {
 		d_fprintf(stderr, _("Error creating share %s: %s\n"),
 			  sharename, win_errstr(werr));
-		goto done;
+		goto cancel;
 	}
 
 	/*
@@ -709,7 +720,7 @@ static int net_conf_addshare(struct net_context *c,
 	if (!W_ERROR_IS_OK(werr)) {
 		d_fprintf(stderr, _("Error setting parameter %s: %s\n"),
 			  "path", win_errstr(werr));
-		goto done;
+		goto cancel;
 	}
 
 	if (comment != NULL) {
@@ -718,7 +729,7 @@ static int net_conf_addshare(struct net_context *c,
 		if (!W_ERROR_IS_OK(werr)) {
 			d_fprintf(stderr, _("Error setting parameter %s: %s\n"),
 				  "comment", win_errstr(werr));
-			goto done;
+			goto cancel;
 		}
 	}
 
@@ -726,7 +737,7 @@ static int net_conf_addshare(struct net_context *c,
 	if (!W_ERROR_IS_OK(werr)) {
 		d_fprintf(stderr, _("Error setting parameter %s: %s\n"),
 			  "'guest ok'", win_errstr(werr));
-		goto done;
+		goto cancel;
 	}
 
 	werr = smbconf_set_parameter(conf_ctx, sharename, "writeable",
@@ -734,10 +745,29 @@ static int net_conf_addshare(struct net_context *c,
 	if (!W_ERROR_IS_OK(werr)) {
 		d_fprintf(stderr, _("Error setting parameter %s: %s\n"),
 			  "writeable", win_errstr(werr));
-		goto done;
+		goto cancel;
 	}
 
-	ret = 0;
+	/*
+	 * commit the whole thing
+	 */
+
+	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);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list