[PATCH 2 of 2] (perf) Use cached values to deterimine elevation

Wald Commits scm-commit at wald.intevation.org
Mon Oct 13 12:32:20 CEST 2014


# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1413196333 -7200
# Node ID 2bacaec6e1012ca94d19c4421655974f9082c5ea
# Parent  845048d4a69f3f434efb2c92b80841d6a64fd1f9
(perf) Use cached values to deterimine elevation.

diff -r 845048d4a69f -r 2bacaec6e101 common/util.c
--- a/common/util.c	Mon Oct 13 12:31:37 2014 +0200
+++ b/common/util.c	Mon Oct 13 12:32:13 2014 +0200
@@ -453,10 +453,17 @@
 }
 #endif
 
+static bool g_is_elevated = false;
+static bool g_elevated_initalized = false;
+
 bool
 is_elevated()
 {
   bool ret = false;
+  if (g_elevated_initalized)
+    {
+      return g_is_elevated;
+    }
 #ifndef _WIN32
   ret = (geteuid() == 0);
 #else
@@ -481,6 +488,8 @@
   if (hToken)
     CloseHandle (hToken);
 #endif
+  g_is_elevated = ret;
+  g_elevated_initalized = true;
   return ret;
 }
 


More information about the Trustbridge-commits mailing list