Skip to content

Commit

Permalink
more 5076 - sync cache
Browse files Browse the repository at this point in the history
  • Loading branch information
alabuzhev committed Oct 26, 2017
1 parent d32bb66 commit 51288e3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions far/changelog
@@ -1,3 +1,7 @@
drkns 26.10.2017 23:03:02 +0100 - build 5077

1. Уточнение 5076.2 - синхронизация кеширования.

drkns 26.10.2017 20:06:28 +0100 - build 5076

1. С форума: падение на операции удаления с повышением прав.
Expand Down
10 changes: 8 additions & 2 deletions far/privilege.cpp
Expand Up @@ -35,6 +35,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "privilege.hpp"
#include "lasterror.hpp"
#include "synchro.hpp"


namespace os::security {
Expand All @@ -48,8 +49,12 @@ static handle OpenCurrentProcessToken(DWORD DesiredAccess)
static bool lookup_privilege_value(const wchar_t* Name, LUID& Value)
{
using value_type = std::pair<LUID, bool>;
static std::unordered_map<string, value_type> sCache;
auto Result = sCache.emplace(Name, value_type{});
static std::unordered_map<string, value_type> s_Cache;
static os::critical_section s_CS;

SCOPED_ACTION(os::critical_section_lock)(s_CS);

auto Result = s_Cache.emplace(Name, value_type{});

const auto& MapKey = Result.first->first;
auto& MapValue = Result.first->second;
Expand All @@ -62,6 +67,7 @@ static bool lookup_privilege_value(const wchar_t* Name, LUID& Value)
Value = MapValue.first;
return MapValue.second;
}

privilege::privilege(const range<const wchar_t* const*>& Names)
{
if (Names.empty())
Expand Down
2 changes: 1 addition & 1 deletion far/vbuild.m4
@@ -1 +1 @@
m4_define(BUILD,5076)m4_dnl
m4_define(BUILD,5077)m4_dnl

0 comments on commit 51288e3

Please sign in to comment.