Mercurial > trustbridge
changeset 1307:2bacaec6e101
(perf) Use cached values to deterimine elevation.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 13 Oct 2014 12:32:13 +0200 |
parents | 845048d4a69f |
children | fce8c122cbc4 |
files | common/util.c |
diffstat | 1 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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; }