Summary: | Ktorrent crashed while stopping download | ||
---|---|---|---|
Product: | [Applications] ktorrent | Reporter: | Kawe <4u2strong> |
Component: | general | Assignee: | Joris Guisson <joris.guisson> |
Status: | RESOLVED FIXED | ||
Severity: | crash | CC: | bareil76 |
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Ubuntu | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
Kawe
2010-11-17 10:41:51 UTC
Can you send me that torrent ? Am Mittwoch 17 November 2010, um 18:07:01 schrieb Joris Guisson:
> https://bugs.kde.org/show_bug.cgi?id=257126
>
> --- Comment #1 from Joris Guisson <joris guisson gmail com>
> 2010-11-17 18:06:59 --- Can you send me that torrent ?
Sure :-)
rgds
Kawe
commit d0b766ea1e2c383ba70e57d6d498207f1115ff30 branch master Author: Joris <joris.guisson@gmail.com> Date: Tue Nov 30 20:19:06 2010 +0100 Use weak pointers in PeerConnector and Authenticate, should fix a crash. BUG: 257126 diff --git a/ChangeLog b/ChangeLog index 4b042a3..67132d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21,6 +21,7 @@ Changes in 1.1: - Revamp PieceData management, fixes a crash (247984) - Add support for warning message parameter in tracker replies - Make sure connection setup slots are distributed fairly to avoid starvation +- Use weak pointers in PeerConnector and Authenticate (258207) Changes in 1.0.5: - Update PeerID client identifications diff --git a/src/peer/authenticate.cpp b/src/peer/authenticate.cpp index 1d8c6f3..75d6654 100644 --- a/src/peer/authenticate.cpp +++ b/src/peer/authenticate.cpp @@ -161,8 +161,9 @@ namespace bt sock.clear(); timer.stop(); - if (pcon) - pcon->authenticationFinished(this,succes); + PeerConnector* pc = pcon.data(); + if (pc) + pc->authenticationFinished(this,succes); } void Authenticate::handshakeReceived(bool full) diff --git a/src/peer/authenticate.h b/src/peer/authenticate.h index 68714a5..163d363 100644 --- a/src/peer/authenticate.h +++ b/src/peer/authenticate.h @@ -90,7 +90,7 @@ namespace bt QString host; Uint16 port; bool succes; - PeerConnector* pcon; + QWeakPointer<PeerConnector> pcon; net::Socks* socks; }; } diff --git a/src/peer/peerconnector.cpp b/src/peer/peerconnector.cpp index a82cd79..8f43f3d 100644 --- a/src/peer/peerconnector.cpp +++ b/src/peer/peerconnector.cpp @@ -60,13 +60,13 @@ namespace bt QString ip; Uint16 port; bool local; - PeerManager* pman; + QWeakPointer<PeerManager> pman; Authenticate* auth; bool stopping; bool do_not_start; }; - PeerConnector::PeerConnector(const QString & ip,Uint16 port,bool local,PeerManager* pman) + PeerConnector::PeerConnector(const QString& ip, Uint16 port, bool local, bt::PeerManager* pman) : QObject(pman), Resource(&half_open_connections,pman->getTorrent().getInfoHash().toString()), d(new Private(this,ip,port,local,pman)) @@ -87,15 +87,11 @@ namespace bt { half_open_connections.add(this); } - - void PeerConnector::doNotStart() - { - d->do_not_start = true; - } void PeerConnector::acquired() { - if (d->do_not_start) + PeerManager* pm = d->pman.data(); + if (!pm || !pm->isStarted()) return; bool encryption = ServerInterface::isEncryptionEnabled(); @@ -149,9 +145,13 @@ namespace bt if (stopping) return; + PeerManager* pm = pman.data(); + if (!pm) + return; + if (ok) { - pman->peerAuthenticated(auth,p,ok); + pm->peerAuthenticated(auth,p,ok); return; } @@ -177,15 +177,19 @@ namespace bt allowed.removeAll(m); if (allowed.isEmpty()) - pman->peerAuthenticated(auth,p,false); + pm->peerAuthenticated(auth,p,false); else start(allowed.front()); } void PeerConnector::Private::start(PeerConnector::Method method) { + PeerManager* pm = pman.data(); + if (!pm) + return; + current_method = method; - const Torrent & tor = pman->getTorrent(); + const Torrent & tor = pm->getTorrent(); TransportProtocol proto = (method == TCP_WITH_ENCRYPTION || method == TCP_WITHOUT_ENCRYPTION) ? TCP : UTP; if (method == TCP_WITH_ENCRYPTION || method == UTP_WITH_ENCRYPTION) auth = new mse::EncryptedAuthenticate(ip,port,proto,tor.getInfoHash(),tor.getPeerID(),p); diff --git a/src/peer/peerconnector.h b/src/peer/peerconnector.h index 2311c89..74239dd 100644 --- a/src/peer/peerconnector.h +++ b/src/peer/peerconnector.h @@ -60,17 +60,10 @@ namespace bt void stop(); /** - Called when all PeerConnector's of a torrent are being removed. - The PeerConnector should not attempt to start after this call. - */ - void doNotStart(); - - /** * Set the maximum number of active PeerConnectors allowed */ static void setMaxActive(Uint32 mc); - typedef QSharedPointer<PeerConnector> Ptr; private: virtual void acquired(); diff --git a/src/peer/peermanager.cpp b/src/peer/peermanager.cpp index 5d0aa19..e7eedce 100644 --- a/src/peer/peermanager.cpp +++ b/src/peer/peermanager.cpp @@ -429,15 +429,7 @@ namespace bt d->available_chunks.clear(); d->started = false; ServerInterface::removePeerManager(this); - - // Tell all PeerConnector's that they should not start from now on - foreach (PeerConnector* pcon,d->connectors) - pcon->doNotStart(); - - // Use copy so that connectors can be safely emptied - QSet<PeerConnector*> connectors_copy = d->connectors; - foreach (PeerConnector* pcon,connectors_copy) - pcon->stop(); + d->connectors.clear(); if (d->superseeder) { @@ -694,10 +686,8 @@ namespace bt delete superseeder; - // Tell all PeerConnector's that they should not start from now on - foreach (PeerConnector* pcon,connectors) - pcon->doNotStart(); - qDeleteAll(connectors); + started = false; + connectors.clear(); } void PeerManager::Private::update() *** Bug 258295 has been marked as a duplicate of this bug. *** |