linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #07078
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 3315: Prevent races when sending INF/MyINFO
------------------------------------------------------------
revno: 3315
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Tue 2013-06-25 13:26:24 +0200
message:
Prevent races when sending INF/MyINFO
modified:
changelog.txt
dcpp/AdcHub.cpp
dcpp/AdcHub.h
dcpp/Client.cpp
dcpp/Client.h
dcpp/NmdcHub.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 'changelog.txt'
--- changelog.txt 2013-06-18 17:46:46 +0000
+++ changelog.txt 2013-06-25 11:26:24 +0000
@@ -1,4 +1,5 @@
* Translation fixes
+* [L#1194299] Prevent races when sending INF/MyINFO (maksis, poy)
-- 0.825 2013-06-18 --
* [L#1191099] Group partial file list uploads to avoid a crash (poy)
=== modified file 'dcpp/AdcHub.cpp'
--- dcpp/AdcHub.cpp 2013-06-17 21:09:16 +0000
+++ dcpp/AdcHub.cpp 2013-06-25 11:26:24 +0000
@@ -239,7 +239,7 @@
sid = AdcCommand::toSID(c.getParam(0));
state = STATE_IDENTIFY;
- info(true);
+ infoImpl();
}
void AdcHub::handle(AdcCommand::MSG, AdcCommand& c) noexcept {
@@ -970,7 +970,7 @@
}
}
-void AdcHub::info(bool /*alwaysSend*/) {
+void AdcHub::infoImpl() {
if(state != STATE_IDENTIFY && state != STATE_NORMAL)
return;
=== modified file 'dcpp/AdcHub.h'
--- dcpp/AdcHub.h 2013-01-18 21:28:38 +0000
+++ dcpp/AdcHub.h 2013-06-25 11:26:24 +0000
@@ -42,7 +42,7 @@
virtual void sendUserCmd(const UserCommand& command, const ParamMap& params);
virtual void search(int aSizeMode, int64_t aSize, int aFileType, const string& aString, const string& aToken, const StringList& aExtList);
virtual void password(const string& pwd);
- virtual void info(bool alwaysSend);
+ virtual void infoImpl();
virtual size_t getUserCount() const { Lock l(cs); return users.size(); }
virtual int64_t getAvailable() const;
=== modified file 'dcpp/Client.cpp'
--- dcpp/Client.cpp 2013-01-29 15:38:58 +0000
+++ dcpp/Client.cpp 2013-06-25 11:26:24 +0000
@@ -126,6 +126,10 @@
updateActivity();
}
+void Client::info() {
+ sock->callAsync([this] { infoImpl(); });
+}
+
void Client::send(const char* aMessage, size_t aLen) {
if(!isConnected()) {
dcassert(0);
=== modified file 'dcpp/Client.h'
--- dcpp/Client.h 2013-01-29 15:38:58 +0000
+++ dcpp/Client.h 2013-06-25 11:26:24 +0000
@@ -54,7 +54,8 @@
virtual void sendUserCmd(const UserCommand& command, const ParamMap& params) = 0;
virtual void search(int aSizeMode, int64_t aSize, int aFileType, const string& aString, const string& aToken, const StringList& aExtList) = 0;
virtual void password(const string& pwd) = 0;
- virtual void info(bool force) = 0;
+ /** Send new information about oneself. Thread-safe. */
+ void info();
virtual size_t getUserCount() const = 0;
virtual int64_t getAvailable() const = 0;
@@ -133,6 +134,7 @@
BufferedSocket *sock;
+ /** Update hub counts. Thread-safe. */
void updateCounts(bool aRemove);
void updateActivity() { lastActivity = GET_TICK(); }
@@ -159,6 +161,7 @@
private:
virtual OnlineUserList getUsers() const = 0;
+ virtual void infoImpl() = 0;
string hubUrl;
string address;
=== modified file 'dcpp/NmdcHub.h'
--- dcpp/NmdcHub.h 2013-01-18 21:28:38 +0000
+++ dcpp/NmdcHub.h 2013-06-25 11:26:24 +0000
@@ -46,7 +46,7 @@
virtual void sendUserCmd(const UserCommand& command, const ParamMap& params);
virtual void search(int aSizeType, int64_t aSize, int aFileType, const string& aString, const string& aToken, const StringList& aExtList);
virtual void password(const string& aPass) { send("$MyPass " + fromUtf8(aPass) + "|"); }
- virtual void info(bool force) { myInfo(force); }
+ virtual void infoImpl() { myInfo(false); }
virtual size_t getUserCount() const { Lock l(cs); return users.size(); }
virtual int64_t getAvailable() const;