s3: Wrap creating the svcctl keys in a transaction
authorVolker Lendecke <vl@samba.org>
Sat, 9 Apr 2011 16:15:12 +0000 (18:15 +0200)
committerVolker Lendecke <vlendec@samba.org>
Mon, 11 Apr 2011 20:09:58 +0000 (22:09 +0200)
This makes the startup of smbd in make test much quicker and thus more reliable
(cherry picked from commit f1aa38b414e97d8687d0bebf65baa384f75301b4)

Autobuild-User: Volker Lendecke <vlendec@samba.org>
Autobuild-Date: Mon Apr 11 22:09:58 CEST 2011 on sn-devel-104

source3/rpc_server/svcctl/srv_svcctl_reg.c

index d262ff83b782a73946a35b7847c80900043703c2..eb0c2bddb6b65e5fa77d15dceb44ce73f1070df1 100644 (file)
@@ -30,6 +30,7 @@
 #include "rpc_client/cli_winreg.h"
 #include "rpc_server/svcctl/srv_svcctl_reg.h"
 #include "auth.h"
+#include "registry/reg_backend_db.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_REGISTRY
@@ -575,6 +576,19 @@ bool svcctl_init_winreg(struct messaging_context *msg_ctx)
                goto done;
        }
 
+       result = regdb_open();
+       if (!W_ERROR_IS_OK(result)) {
+               DEBUG(10, ("regdb_open failed: %s\n",
+                          win_errstr(result)));
+               goto done;
+       }
+       result = regdb_transaction_start();
+       if (!W_ERROR_IS_OK(result)) {
+               DEBUG(10, ("regdb_transaction_start failed: %s\n",
+                          win_errstr(result)));
+               goto done;
+       }
+
        status = dcerpc_winreg_int_hklm_openkey(tmp_ctx,
                                                get_session_info_system(),
                                                msg_ctx,
@@ -674,6 +688,20 @@ done:
                dcerpc_winreg_CloseKey(h, tmp_ctx, &key_hnd, &result);
        }
 
+       if (ok) {
+               result = regdb_transaction_commit();
+               if (!W_ERROR_IS_OK(result)) {
+                       DEBUG(10, ("regdb_transaction_commit failed: %s\n",
+                                  win_errstr(result)));
+               }
+       } else {
+               result = regdb_transaction_cancel();
+               if (!W_ERROR_IS_OK(result)) {
+                       DEBUG(10, ("regdb_transaction_cancel failed: %s\n",
+                                  win_errstr(result)));
+               }
+       }
+       regdb_close();
        return ok;
 }