Bug 257126 - Ktorrent crashed while stopping download
Summary: Ktorrent crashed while stopping download
Status: RESOLVED FIXED
Alias: None
Product: ktorrent
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: NOR crash
Target Milestone: ---
Assignee: Joris Guisson
URL:
Keywords:
: 258295 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-11-17 10:41 UTC by Kawe
Modified: 2010-11-30 20:27 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kawe 2010-11-17 10:41:51 UTC
Application: ktorrent (4.0.3)
KDE Platform Version: 4.5.1 (KDE 4.5.1)
Qt Version: 4.7.0
Operating System: Linux 2.6.32-25-generic x86_64
Distribution: Linux Mint 9 Isadora

-- Information about the crash:
Stopping the download of one file (interrupt). No other downloads.

The crash can be reproduced every time.

-- Backtrace:
Application: KTorrent (ktorrent), signal: Segmentation fault
[Current thread is 1 (Thread 0x7f8f18fe6760 (LWP 10068))]

Thread 11 (Thread 0x7f8efffff710 (LWP 10070)):
#0  0x00007fffa4f46904 in clock_gettime ()
#1  0x00007f8f0fc0109f in *__GI_clock_gettime (clock_id=1, tp=0x7f8effffea90) at ../sysdeps/unix/clock_gettime.c:100
#2  0x00007f8f1654a4af in do_gettime () at tools/qelapsedtimer_unix.cpp:105
#3  qt_gettime () at tools/qelapsedtimer_unix.cpp:119
#4  0x00007f8f166161ed in QTimerInfoList::updateCurrentTime (this=0x1) at kernel/qeventdispatcher_unix.cpp:339
#5  0x00007f8f1661746c in QTimerInfoList::activateTimers (this=0x24bdb50) at kernel/qeventdispatcher_unix.cpp:561
#6  0x00007f8f166144b8 in timerSourceDispatch (source=<value optimized out>) at kernel/qeventdispatcher_glib.cpp:184
#7  idleTimerSourceDispatch (source=<value optimized out>) at kernel/qeventdispatcher_glib.cpp:231
#8  0x00007f8f0f95d8c2 in g_main_context_dispatch () from /lib/libglib-2.0.so.0
#9  0x00007f8f0f961748 in ?? () from /lib/libglib-2.0.so.0
#10 0x00007f8f0f9618fc in g_main_context_iteration () from /lib/libglib-2.0.so.0
#11 0x00007f8f16614183 in QEventDispatcherGlib::processEvents (this=0x23c38c0, flags=<value optimized out>) at kernel/qeventdispatcher_glib.cpp:415
#12 0x00007f8f165e6dd2 in QEventLoop::processEvents (this=<value optimized out>, flags=) at kernel/qeventloop.cpp:149
#13 0x00007f8f165e71bc in QEventLoop::exec (this=0x7f8effffedb0, flags=) at kernel/qeventloop.cpp:201
#14 0x00007f8f164f236d in QThread::exec (this=<value optimized out>) at thread/qthread.cpp:490
#15 0x00007f8f18b9891e in utp::UTPServerThread::run (this=0x24c24c0) at ../../src/utp/utpserverthread.cpp:44
#16 0x00007f8f164f52ee in QThreadPrivate::start (arg=0x24c24c0) at thread/qthread_unix.cpp:266
#17 0x00007f8f162639ca in start_thread (arg=<value optimized out>) at pthread_create.c:300
#18 0x00007f8f14b2170d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#19 0x0000000000000000 in ?? ()

Thread 10 (Thread 0x7f8eff7fe710 (LWP 10071)):
#0  0x00007f8f14b19ff3 in select () at ../sysdeps/unix/syscall-template.S:82
#1  0x00007f8f18b5ffa2 in dht::RPCServerThread::run (this=0x252c2f0) at ../../src/dht/rpcserver.cpp:107
#2  0x00007f8f164f52ee in QThreadPrivate::start (arg=0x252c2f0) at thread/qthread_unix.cpp:266
#3  0x00007f8f162639ca in start_thread (arg=<value optimized out>) at pthread_create.c:300
#4  0x00007f8f14b2170d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#5  0x0000000000000000 in ?? ()

Thread 9 (Thread 0x7f8efeffd710 (LWP 10079)):
#0  pthread_cond_timedwait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:211
#1  0x00007f8ef7839081 in ?? () from /usr/lib/libxine.so.1
#2  0x00007f8f162639ca in start_thread (arg=<value optimized out>) at pthread_create.c:300
#3  0x00007f8f14b2170d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#4  0x0000000000000000 in ?? ()

Thread 8 (Thread 0x7f8efe7fc710 (LWP 10080)):
#0  0x00007fffa4f46904 in clock_gettime ()
#1  0x00007f8f0fc0109f in *__GI_clock_gettime (clock_id=1, tp=0x7f8efe7fbac0) at ../sysdeps/unix/clock_gettime.c:100
#2  0x00007f8f1654a4af in do_gettime () at tools/qelapsedtimer_unix.cpp:105
#3  qt_gettime () at tools/qelapsedtimer_unix.cpp:119
#4  0x00007f8f166161ed in QTimerInfoList::updateCurrentTime (this=0x1) at kernel/qeventdispatcher_unix.cpp:339
#5  0x00007f8f16616215 in QTimerInfoList::timerWait (this=0x1, tm=...) at kernel/qeventdispatcher_unix.cpp:442
#6  0x00007f8f166143cd in timerSourcePrepareHelper (src=<value optimized out>, timeout=0x7f8efe7fbbfc) at kernel/qeventdispatcher_glib.cpp:136
#7  0x00007f8f16614475 in timerSourcePrepare (source=0x1, timeout=0x7f8efe7fbac0) at kernel/qeventdispatcher_glib.cpp:169
#8  0x00007f8f0f960eb1 in g_main_context_prepare () from /lib/libglib-2.0.so.0
#9  0x00007f8f0f961318 in ?? () from /lib/libglib-2.0.so.0
#10 0x00007f8f0f9618fc in g_main_context_iteration () from /lib/libglib-2.0.so.0
#11 0x00007f8f166141d6 in QEventDispatcherGlib::processEvents (this=0x286f340, flags=<value optimized out>) at kernel/qeventdispatcher_glib.cpp:417
#12 0x00007f8f165e6dd2 in QEventLoop::processEvents (this=<value optimized out>, flags=) at kernel/qeventloop.cpp:149
#13 0x00007f8f165e71bc in QEventLoop::exec (this=0x7f8efe7fbd90, flags=) at kernel/qeventloop.cpp:201
#14 0x00007f8f164f236d in QThread::exec (this=<value optimized out>) at thread/qthread.cpp:490
#15 0x00007f8ef7a952b0 in ?? () from /usr/lib/qt4/plugins/phonon_backend/phonon_xine.so
#16 0x00007f8f164f52ee in QThreadPrivate::start (arg=0x27e2400) at thread/qthread_unix.cpp:266
#17 0x00007f8f162639ca in start_thread (arg=<value optimized out>) at pthread_create.c:300
#18 0x00007f8f14b2170d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#19 0x0000000000000000 in ?? ()

Thread 7 (Thread 0x7f8efdffb710 (LWP 10081)):
#0  0x00007f8f14b14f93 in *__GI___poll (fds=<value optimized out>, nfds=<value optimized out>, timeout=333) at ../sysdeps/unix/sysv/linux/poll.c:87
#1  0x00007f8ef252d915 in ?? () from /usr/lib/xine/plugins/1.27/xineplug_ao_out_alsa.so
#2  0x00007f8f162639ca in start_thread (arg=<value optimized out>) at pthread_create.c:300
#3  0x00007f8f14b2170d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#4  0x0000000000000000 in ?? ()

Thread 6 (Thread 0x7f8f04f66710 (LWP 10082)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:162
#1  0x00007f8ef7849e23 in ?? () from /usr/lib/libxine.so.1
#2  0x00007f8f162639ca in start_thread (arg=<value optimized out>) at pthread_create.c:300
#3  0x00007f8f14b2170d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#4  0x0000000000000000 in ?? ()

Thread 5 (Thread 0x7f8eea9b2710 (LWP 10100)):
#0  0x00007fffa4f46904 in clock_gettime ()
#1  0x00007f8f0fc0109f in *__GI_clock_gettime (clock_id=1, tp=0x7f8eea9b1ae0) at ../sysdeps/unix/clock_gettime.c:100
#2  0x00007f8f1654a4af in do_gettime () at tools/qelapsedtimer_unix.cpp:105
#3  qt_gettime () at tools/qelapsedtimer_unix.cpp:119
#4  0x00007f8f166161ed in QTimerInfoList::updateCurrentTime (this=0x1) at kernel/qeventdispatcher_unix.cpp:339
#5  0x00007f8f16616215 in QTimerInfoList::timerWait (this=0x1, tm=...) at kernel/qeventdispatcher_unix.cpp:442
#6  0x00007f8f166143cd in timerSourcePrepareHelper (src=<value optimized out>, timeout=0x7f8eea9b1c1c) at kernel/qeventdispatcher_glib.cpp:136
#7  0x00007f8f16614475 in timerSourcePrepare (source=0x1, timeout=0x7f8eea9b1ae0) at kernel/qeventdispatcher_glib.cpp:169
#8  0x00007f8f0f960eb1 in g_main_context_prepare () from /lib/libglib-2.0.so.0
#9  0x00007f8f0f961318 in ?? () from /lib/libglib-2.0.so.0
#10 0x00007f8f0f9618fc in g_main_context_iteration () from /lib/libglib-2.0.so.0
#11 0x00007f8f166141d6 in QEventDispatcherGlib::processEvents (this=0x24a97e0, flags=<value optimized out>) at kernel/qeventdispatcher_glib.cpp:417
#12 0x00007f8f165e6dd2 in QEventLoop::processEvents (this=<value optimized out>, flags=) at kernel/qeventloop.cpp:149
#13 0x00007f8f165e71bc in QEventLoop::exec (this=0x7f8eea9b1db0, flags=) at kernel/qeventloop.cpp:201
#14 0x00007f8f164f236d in QThread::exec (this=<value optimized out>) at thread/qthread.cpp:490
#15 0x00007f8f165c6b48 in QInotifyFileSystemWatcherEngine::run (this=0x2dd0720) at io/qfilesystemwatcher_inotify.cpp:248
#16 0x00007f8f164f52ee in QThreadPrivate::start (arg=0x2dd0720) at thread/qthread_unix.cpp:266
#17 0x00007f8f162639ca in start_thread (arg=<value optimized out>) at pthread_create.c:300
#18 0x00007f8f14b2170d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#19 0x0000000000000000 in ?? ()

Thread 4 (Thread 0x7f8ee786c710 (LWP 10152)):
#0  pthread_cond_timedwait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:211
#1  0x00007f8f164f48b5 in thread_sleep (ti=0x7f8ee786bda0) at thread/qthread_unix.cpp:416
#2  0x00007f8f164f4a20 in QThread::msleep (msecs=<value optimized out>) at thread/qthread_unix.cpp:442
#3  0x00007f8f18afe24d in net::DownloadThread::update (this=0x2383ab0) at ../../src/net/downloadthread.cpp:91
#4  0x00007f8f18afeb39 in net::NetworkThread::run (this=0x2383ab0) at ../../src/net/networkthread.cpp:48
#5  0x00007f8f164f52ee in QThreadPrivate::start (arg=0x2383ab0) at thread/qthread_unix.cpp:266
#6  0x00007f8f162639ca in start_thread (arg=<value optimized out>) at pthread_create.c:300
#7  0x00007f8f14b2170d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#8  0x0000000000000000 in ?? ()

Thread 3 (Thread 0x7f8ee706b710 (LWP 10153)):
#0  pthread_cond_timedwait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:211
#1  0x00007f8f164f48b5 in thread_sleep (ti=0x7f8ee706ada0) at thread/qthread_unix.cpp:416
#2  0x00007f8f164f4a20 in QThread::msleep (msecs=<value optimized out>) at thread/qthread_unix.cpp:442
#3  0x00007f8f18afd8fd in net::UploadThread::update (this=0x2384120) at ../../src/net/uploadthread.cpp:89
#4  0x00007f8f18afeb39 in net::NetworkThread::run (this=0x2384120) at ../../src/net/networkthread.cpp:48
#5  0x00007f8f164f52ee in QThreadPrivate::start (arg=0x2384120) at thread/qthread_unix.cpp:266
#6  0x00007f8f162639ca in start_thread (arg=<value optimized out>) at pthread_create.c:300
#7  0x00007f8f14b2170d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#8  0x0000000000000000 in ?? ()

Thread 2 (Thread 0x7f8ee5868710 (LWP 10154)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:162
#1  0x00007f8f164f5eab in QWaitConditionPrivate::wait (this=<value optimized out>, mutex=0x24e16e0, time=18446744073709551615) at thread/qwaitcondition_unix.cpp:88
#2  QWaitCondition::wait (this=<value optimized out>, mutex=0x24e16e0, time=18446744073709551615) at thread/qwaitcondition_unix.cpp:160
#3  0x00007f8f18b01b42 in net::ReverseResolverThread::run (this=0x24e16d0) at ../../src/net/reverseresolver.cpp:123
#4  0x00007f8f164f52ee in QThreadPrivate::start (arg=0x24e16d0) at thread/qthread_unix.cpp:266
#5  0x00007f8f162639ca in start_thread (arg=<value optimized out>) at pthread_create.c:300
#6  0x00007f8f14b2170d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#7  0x0000000000000000 in ?? ()

Thread 1 (Thread 0x7f8f18fe6760 (LWP 10068)):
[KCrash Handler]
#6  0x00000000006d7e60 in QObject::staticMetaObject ()
#7  0x00007f8f18b12b45 in bt::PeerManager::stop (this=0x26126f0) at ../../src/peer/peermanager.cpp:550
#8  0x00007f8f18b4481f in bt::TorrentControl::stop (this=0x25b3d00, wjob=0x0) at ../../src/torrent/torrentcontrol.cpp:486
#9  0x00007f8f188410fa in kt::QueueManager::stopSafely (this=<value optimized out>, tc=0x25b3d00, wjob=0x2cfda10) at ../../libktcore/torrent/queuemanager.cpp:752
#10 0x00007f8f18845432 in kt::QueueManager::stop (this=0x7f8f000009f0, todo=<value optimized out>) at ../../libktcore/torrent/queuemanager.cpp:222
#11 0x000000000048aa49 in kt::View::stopTorrents (this=0x2cbc9a0) at ../../ktorrent/view/view.cpp:195
#12 0x00000000004960b4 in kt::ViewManager::qt_metacall (this=0x24e99b0, _c=QMetaObject::InvokeMetaMethod, _id=47176208, _a=0x7fffa4f3d840) at ./viewmanager.moc:131
#13 0x00007f8f165ffda7 in QMetaObject::activate (sender=0x24eaf90, m=<value optimized out>, local_signal_index=<value optimized out>, argv=0x2cfda00) at kernel/qobject.cpp:3280
#14 0x00007f8f1572f002 in QAction::triggered (this=0x3056d30, _t1=false) at .moc/release-shared/moc_qaction.cpp:263
#15 0x00007f8f157306fb in QAction::activate (this=0x24eaf90, event=<value optimized out>) at kernel/qaction.cpp:1256
#16 0x00007f8f15b0b2da in QAbstractButtonPrivate::click (this=0x25e83e0) at widgets/qabstractbutton.cpp:528
#17 0x00007f8f15b0b58c in QAbstractButton::mouseReleaseEvent (this=0x25ccf90, e=0x7fffa4f3e180) at widgets/qabstractbutton.cpp:1121
#18 0x00007f8f15bda4fa in QToolButton::mouseReleaseEvent (this=0x3056d30, e=0x0) at widgets/qtoolbutton.cpp:721
#19 0x00007f8f1578c48e in QWidget::event (this=0x25ccf90, event=0x7fffa4f3e180) at kernel/qwidget.cpp:8187
#20 0x00007f8f157366ec in QApplicationPrivate::notify_helper (this=0x23b0530, receiver=0x25ccf90, e=0x7fffa4f3e180) at kernel/qapplication.cpp:4396
#21 0x00007f8f1573c9fe in QApplication::notify (this=0x7fffa4f3ee60, receiver=0x25ccf90, e=0x7fffa4f3e180) at kernel/qapplication.cpp:3959
#22 0x0000000000439f0a in kt::App::notify (this=0x3056d30, receiver=0x0, event=0x2cfda10) at ../../ktorrent/app.cpp:97
#23 0x00007f8f165e80ac in QCoreApplication::notifyInternal (this=0x7fffa4f3ee60, receiver=0x25ccf90, event=0x7fffa4f3e180) at kernel/qcoreapplication.cpp:732
#24 0x00007f8f1573b4ae in QCoreApplication::sendEvent (receiver=0x25ccf90, event=0x7fffa4f3e180, alienWidget=0x25ccf90, nativeWidget=0x25ac490, buttonDown=<value optimized out>, 
    lastMouseReceiver=<value optimized out>, spontaneous=true) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:215
#25 QApplicationPrivate::sendMouseEvent (receiver=0x25ccf90, event=0x7fffa4f3e180, alienWidget=0x25ccf90, nativeWidget=0x25ac490, buttonDown=<value optimized out>, 
    lastMouseReceiver=<value optimized out>, spontaneous=true) at kernel/qapplication.cpp:3058
#26 0x00007f8f157be4a5 in QETWidget::translateMouseEvent (this=0x25ac490, event=<value optimized out>) at kernel/qapplication_x11.cpp:4403
#27 0x00007f8f157bcddc in QApplication::x11ProcessEvent (this=<value optimized out>, event=0x7fffa4f3eaa0) at kernel/qapplication_x11.cpp:3536
#28 0x00007f8f157e9012 in x11EventSourceDispatch (s=0x23bf740, callback=<value optimized out>, user_data=<value optimized out>) at kernel/qguieventdispatcher_glib.cpp:146
#29 0x00007f8f0f95d8c2 in g_main_context_dispatch () from /lib/libglib-2.0.so.0
#30 0x00007f8f0f961748 in ?? () from /lib/libglib-2.0.so.0
#31 0x00007f8f0f9618fc in g_main_context_iteration () from /lib/libglib-2.0.so.0
#32 0x00007f8f16614183 in QEventDispatcherGlib::processEvents (this=0x2381aa0, flags=<value optimized out>) at kernel/qeventdispatcher_glib.cpp:415
#33 0x00007f8f157e897e in QGuiEventDispatcherGlib::processEvents (this=0x3056d30, flags=<value optimized out>) at kernel/qguieventdispatcher_glib.cpp:204
#34 0x00007f8f165e6dd2 in QEventLoop::processEvents (this=<value optimized out>, flags=) at kernel/qeventloop.cpp:149
#35 0x00007f8f165e71bc in QEventLoop::exec (this=0x7fffa4f3edd0, flags=) at kernel/qeventloop.cpp:201
#36 0x00007f8f165eb26b in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1009
#37 0x000000000042909b in main (argc=<value optimized out>, argv=<value optimized out>) at ../../ktorrent/main.cpp:176

Reported using DrKonqi
Comment 1 Joris Guisson 2010-11-17 18:06:59 UTC
Can you send me that torrent ?
Comment 2 Kawe 2010-11-17 18:54:41 UTC
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
Comment 3 Joris Guisson 2010-11-30 20:24:29 UTC
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()
Comment 4 Joris Guisson 2010-11-30 20:27:27 UTC
*** Bug 258295 has been marked as a duplicate of this bug. ***