------------------------------------------------------------
revno: 3022
committer: iceman50 <[email protected]>
branch nick: dcplusplus
timestamp: Fri 2012-08-03 14:07:49 -0500
message:
partially revert r3021, guard hasFreeSlot by the mutex
modified:
dcpp/UploadManager.cpp
--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk
Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'dcpp/UploadManager.cpp'
--- dcpp/UploadManager.cpp 2012-08-03 11:40:07 +0000
+++ dcpp/UploadManager.cpp 2012-08-03 19:07:49 +0000
@@ -105,7 +105,7 @@
if(!aSource.isSet(UserConnection::FLAG_HASSLOT)) {
bool hasReserved = hasReservedSlot(aSource.getUser());
bool isFavorite = FavoriteManager::getInstance()->hasSlot(aSource.getUser());
- bool hasFreeSlot = (getFreeSlots() > 0) && ((waitingFiles.empty() && connectingUsers.empty()) || isConnecting(aSource.getUser()));
+ bool hasFreeSlot = [&]() -> bool { Lock l(cs); return (getFreeSlots() > 0) && ((waitingFiles.empty() && connectingUsers.empty()) || isConnecting(aSource.getUser())); }();
if(!(hasReserved || isFavorite || getAutoSlot() || hasFreeSlot)) {
bool supportsMini = aSource.isSet(UserConnection::FLAG_SUPPORTS_MINISLOTS);
@@ -284,8 +284,10 @@
}
void UploadManager::reserveSlot(const HintedUser& aUser) {
- Lock l(cs);
- reservedSlots.insert(aUser);
+ {
+ Lock l(cs);
+ reservedSlots.insert(aUser);
+ }
if(aUser.user->isOnline()) {
auto it = find_if(waitingUsers.cbegin(), waitingUsers.cend(), [&](const UserPtr& u) { return u == aUser.user; });
@@ -472,7 +474,6 @@
}
void UploadManager::notifyQueuedUsers() {
- Lock l(cs);
if(waitingUsers.empty()) return; //no users to notify
int freeSlots = getFreeSlots();
_______________________________________________
Mailing list: https://launchpad.net/~linuxdcpp-team
Post to : [email protected]
Unsubscribe : https://launchpad.net/~linuxdcpp-team
More help : https://help.launchpad.net/ListHelp