diff options
author | Mikkel Krautz <mikkel@krautz.dk> | 2016-05-15 18:45:57 +0300 |
---|---|---|
committer | Mikkel Krautz <mikkel@krautz.dk> | 2016-06-24 01:03:12 +0300 |
commit | b1285fc5e330d72e7904220184ee9db8c64b9564 (patch) | |
tree | 2a2070fa2a8d4a0d4c6e99f6bcdbb4ee6ab3a6e0 /src/murmur/RPC.cpp | |
parent | cfb535aa15e23df6b5407d0762a4b1576b29e2e8 (diff) |
Ensure all ACL write operations hold qrwlVoiceThread.
Diffstat (limited to 'src/murmur/RPC.cpp')
-rw-r--r-- | src/murmur/RPC.cpp | 56 |
1 files changed, 32 insertions, 24 deletions
diff --git a/src/murmur/RPC.cpp b/src/murmur/RPC.cpp index 9904b2a5e..962310e6d 100644 --- a/src/murmur/RPC.cpp +++ b/src/murmur/RPC.cpp @@ -402,22 +402,26 @@ void Server::setTempGroups(int userid, int sessionId, Channel *cChannel, const Q if (! cChannel) cChannel = qhChannels.value(0); - Group *g; - foreach(g, cChannel->qhGroups) { - g->qsTemporary.remove(userid); - if (sessionId != 0) - g->qsTemporary.remove(- sessionId); - } - - QString gname; - foreach(gname, groups) { - g = cChannel->qhGroups.value(gname); - if (! g) { - g = new Group(cChannel, gname); + { + QWriteLocker wl(&qrwlVoiceThread); + + Group *g; + foreach(g, cChannel->qhGroups) { + g->qsTemporary.remove(userid); + if (sessionId != 0) + g->qsTemporary.remove(- sessionId); + } + + QString gname; + foreach(gname, groups) { + g = cChannel->qhGroups.value(gname); + if (! g) { + g = new Group(cChannel, gname); + } + g->qsTemporary.insert(userid); + if (sessionId != 0) + g->qsTemporary.insert(- sessionId); } - g->qsTemporary.insert(userid); - if (sessionId != 0) - g->qsTemporary.insert(- sessionId); } User *p = qhUsers.value(userid); @@ -436,16 +440,20 @@ void Server::clearTempGroups(User *user, Channel *cChannel, bool recurse) { qlChans.append(cChannel); - while (!qlChans.isEmpty()) { - Channel *chan = qlChans.takeLast(); - Group *g; - foreach(g, chan->qhGroups) { - g->qsTemporary.remove(user->iId); - g->qsTemporary.remove(- static_cast<int>(user->uiSession)); - } + { + QWriteLocker wl(&qrwlVoiceThread); - if (recurse) - qlChans << chan->qlChannels; + while (!qlChans.isEmpty()) { + Channel *chan = qlChans.takeLast(); + Group *g; + foreach(g, chan->qhGroups) { + g->qsTemporary.remove(user->iId); + g->qsTemporary.remove(-static_cast<int>(user->uiSession)); + } + + if (recurse) + qlChans << chan->qlChannels; + } } clearACLCache(user); |