fix AuthorizationRegistry race

oops.  should only prevent add/remove while iterating,
not concurrent iteration.
This commit is contained in:
Michael Davidsaver
2019-10-08 18:26:15 -07:00
parent f81ebae455
commit 7bc5bc2cbc
2 changed files with 4 additions and 5 deletions

View File

@@ -290,7 +290,7 @@ public:
private:
typedef std::map<int, AuthorizationPlugin::shared_pointer> map_t;
map_t map;
void *busy;
size_t busy;
mutable epicsMutex mutex;
public:

View File

@@ -289,12 +289,11 @@ bool AuthorizationRegistry::remove(const AuthorizationPlugin::shared_pointer& pl
void AuthorizationRegistry::run(const std::tr1::shared_ptr<PeerInfo>& peer)
{
int marker;
{
Guard G(mutex);
if(busy)
throw std::runtime_error("AuthorizationRegistry busy");
busy = &marker;
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<PeerInfo>& peer)
}
{
Guard G(mutex);
assert(busy==&marker);
busy = 0;
assert(busy>=0);
busy--;
}
}