linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #05943
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 3023: Fix the remaining issues with CM::connect running in the UploadManager critical section. Revert t...
------------------------------------------------------------
revno: 3023
committer: iceman50 <bdcdevel@xxxxxxxxx>
branch nick: dcplusplus
timestamp: Tue 2012-08-07 09:49:43 -0500
message:
Fix the remaining issues with CM::connect running in the UploadManager critical section. Revert the sending of QP in NMDC
modified:
dcpp/UploadManager.cpp
dcpp/UserConnection.h
--
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 19:07:49 +0000
+++ dcpp/UploadManager.cpp 2012-08-07 14:49:43 +0000
@@ -290,10 +290,14 @@
}
if(aUser.user->isOnline()) {
- auto it = find_if(waitingUsers.cbegin(), waitingUsers.cend(), [&](const UserPtr& u) { return u == aUser.user; });
- if(it != waitingUsers.cend()) {
- ClientManager::getInstance()->connect(aUser, it->token);
- }
+ auto userToken = [&] () -> string
+ {
+ Lock l(cs);
+ auto it = find_if(waitingUsers.cbegin(), waitingUsers.cend(), [&](const UserPtr& u) { return u == aUser.user; });
+ return (it != waitingUsers.cend()) ? it->token : Util::emptyString;
+ };
+
+ ClientManager::getInstance()->connect(aUser, userToken());
}
}
@@ -474,25 +478,29 @@
}
void UploadManager::notifyQueuedUsers() {
- if(waitingUsers.empty()) return; //no users to notify
-
- int freeSlots = getFreeSlots();
- if(freeSlots > 0) {
- freeSlots -= connectingUsers.size();
- while(!waitingUsers.empty() && freeSlots > 0) {
- // let's keep him in the connectingList until he asks for a file
- WaitingUser queuedUser = waitingUsers.front();
- auto isOnline = queuedUser.user.user->isOnline();
- if(isOnline) {
- clearUserFiles(queuedUser.user);
- connectingUsers[queuedUser.user] = GET_TICK();
- ClientManager::getInstance()->connect(queuedUser.user, queuedUser.token);
- freeSlots--;
- } else {
- clearUserFiles(queuedUser.user);
+ vector<WaitingUser> notifyList;
+ {
+ Lock l(cs);
+ if (waitingUsers.empty()) return; //no users to notify
+
+ int freeslots = getFreeSlots();
+ if(freeslots > 0)
+ {
+ freeslots -= connectingUsers.size();
+ while(!waitingUsers.empty() && freeslots > 0) {
+ // let's keep him in the connectingList until he asks for a file
+ WaitingUser wu = waitingUsers.front();
+ clearUserFiles(wu.user);
+ if(wu.user.user->isOnline()) {
+ connectingUsers[wu.user] = GET_TICK();
+ notifyList.push_back(wu);
+ freeslots--;
+ }
}
}
}
+ for(auto it = notifyList.cbegin(); it != notifyList.cend(); ++it)
+ ClientManager::getInstance()->connect((*it).user, (*it).token);
}
void UploadManager::on(TimerManagerListener::Minute, uint64_t aTick ) noexcept {
=== modified file 'dcpp/UserConnection.h'
--- dcpp/UserConnection.h 2012-08-02 00:25:23 +0000
+++ dcpp/UserConnection.h 2012-08-07 14:49:43 +0000
@@ -115,7 +115,7 @@
bool sendPos = queue_position > 0;
if(isSet(FLAG_NMDC)) {
- send("$MaxedOut" + (sendPos ? (" " + Util::toString(queue_position)) : Util::emptyString) + "|");
+ send("$MaxedOut|");
} else {
AdcCommand cmd(AdcCommand::SEV_RECOVERABLE, AdcCommand::ERROR_SLOTS_FULL, "Slots full");
if(sendPos) {