linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #04628
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2636: Manually reset socket
------------------------------------------------------------
revno: 2636
committer: Jacek Sieka <arnetheduck@xxxxxxxxx>
branch nick: dcplusplus
timestamp: Fri 2011-10-14 12:13:26 +0900
message:
Manually reset socket
modified:
dcpp/Client.cpp
dcpp/Client.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/Client.cpp'
--- dcpp/Client.cpp 2011-10-13 02:26:17 +0000
+++ dcpp/Client.cpp 2011-10-14 03:13:26 +0000
@@ -32,7 +32,7 @@
Client::Client(const string& hubURL, char separator_, bool secure_) :
myIdentity(ClientManager::getInstance()->getMe(), 0),
reconnDelay(120), lastActivity(GET_TICK()), registered(false), autoReconnect(false),
- encoding(Text::systemCharset), state(STATE_DISCONNECTED), sock(NULL, &BufferedSocket::putSocket),
+ encoding(Text::systemCharset), state(STATE_DISCONNECTED), sock(0),
hubUrl(hubURL),separator(separator_),
secure(secure_), countType(COUNT_UNCOUNTED)
{
@@ -59,7 +59,10 @@
}
void Client::shutdown() {
- sock.reset();
+ if(sock) {
+ BufferedSocket::putSocket(sock);
+ sock = 0;
+ }
}
void Client::reloadSettings(bool updateNick) {
@@ -85,7 +88,10 @@
}
void Client::connect() {
- sock.reset();
+ if(sock) {
+ BufferedSocket::putSocket(sock);
+ sock = 0;
+ }
setAutoReconnect(true);
setReconnDelay(120 + Util::rand(0, 60));
@@ -97,11 +103,10 @@
state = STATE_CONNECTING;
try {
- sock.reset(BufferedSocket::getSocket(separator, v4only()));
+ sock = BufferedSocket::getSocket(separator, v4only());
sock->addListener(this);
sock->connect(address, port, secure, BOOLSETTING(ALLOW_UNTRUSTED_HUBS), true);
} catch(const Exception& e) {
- sock.reset();
state = STATE_DISCONNECTED;
fire(ClientListener::Failed(), this, e.getError());
}
=== modified file 'dcpp/Client.h'
--- dcpp/Client.h 2011-09-30 11:33:12 +0000
+++ dcpp/Client.h 2011-10-14 03:13:26 +0000
@@ -123,7 +123,7 @@
STATE_DISCONNECTED, ///< Nothing in particular
} state;
- std::unique_ptr<BufferedSocket, void(*)(BufferedSocket*)> sock;
+ BufferedSocket *sock;
void updateCounts(bool aRemove);
void updateActivity() { lastActivity = GET_TICK(); }