From 61b2ac91210a1d34f47cb480c222b9ae64546180 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 8 Jan 2011 11:51:17 +0100 Subject: s3: Avoid a ton of registry writes at startup Autobuild-User: Volker Lendecke Autobuild-Date: Sat Jan 8 12:39:09 CET 2011 on sn-devel-104 --- source3/services/services_db.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'source3/services') diff --git a/source3/services/services_db.c b/source3/services/services_db.c index ca375d22d4..03f7951b7c 100644 --- a/source3/services/services_db.c +++ b/source3/services/services_db.c @@ -270,6 +270,24 @@ static WERROR svcctl_setvalue(struct registry_key *key, struct registry_value *value) { WERROR wresult; + struct registry_value *existing; + + wresult = reg_queryvalue(talloc_tos(), key, name, &existing); + if (W_ERROR_IS_OK(wresult)) { + bool exists; + + exists = ((value->type == existing->type) && + (data_blob_cmp(&value->data, &existing->data) == 0)); + + TALLOC_FREE(existing); + + if (exists) { + /* + * Avoid an expensive write when not necessary + */ + return WERR_OK; + } + } wresult = reg_setvalue(key, name, value); if (!W_ERROR_IS_OK(wresult)) { -- cgit