From 7bc5bc2cbc41c795de242c55d56eac32d8a28116 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Tue, 8 Oct 2019 18:26:15 -0700 Subject: [PATCH] fix AuthorizationRegistry race oops. should only prevent add/remove while iterating, not concurrent iteration. --- src/remote/pv/security.h | 2 +- src/remote/security.cpp | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/remote/pv/security.h b/src/remote/pv/security.h index 87cab62..b60bb27 100644 --- a/src/remote/pv/security.h +++ b/src/remote/pv/security.h @@ -290,7 +290,7 @@ public: private: typedef std::map map_t; map_t map; - void *busy; + size_t busy; mutable epicsMutex mutex; public: diff --git a/src/remote/security.cpp b/src/remote/security.cpp index 5838028..c3028d1 100644 --- a/src/remote/security.cpp +++ b/src/remote/security.cpp @@ -289,12 +289,11 @@ bool AuthorizationRegistry::remove(const AuthorizationPlugin::shared_pointer& pl void AuthorizationRegistry::run(const std::tr1::shared_ptr& peer) { - int marker; { Guard G(mutex); if(busy) throw std::runtime_error("AuthorizationRegistry busy"); - busy = ▮ + busy++; } for(map_t::iterator it(map.begin()), end(map.end()); it!=end; ++it) { @@ -302,8 +301,8 @@ void AuthorizationRegistry::run(const std::tr1::shared_ptr& peer) } { Guard G(mutex); - assert(busy==&marker); - busy = 0; + assert(busy>=0); + busy--; } }