Skip to content

Commit

Permalink
fix AuthorizationRegistry race
Browse files Browse the repository at this point in the history
oops.  should only prevent add/remove while iterating,
not concurrent iteration.
  • Loading branch information
mdavidsaver committed Oct 10, 2019
1 parent f81ebae commit 7bc5bc2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/remote/pv/security.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ class epicsShareClass AuthorizationRegistry
private:
typedef std::map<int, AuthorizationPlugin::shared_pointer> map_t;
map_t map;
void *busy;
size_t busy;
mutable epicsMutex mutex;
public:

Expand Down
7 changes: 3 additions & 4 deletions src/remote/security.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,21 +289,20 @@ 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)
{
(it->second)->authorize(peer);
}
{
Guard G(mutex);
assert(busy==&marker);
busy = 0;
assert(busy>=0);
busy--;
}
}

Expand Down

0 comments on commit 7bc5bc2

Please sign in to comment.