From kde-bugs-dist Mon Oct 31 21:14:40 2005 From: Joris Guisson Date: Mon, 31 Oct 2005 21:14:40 +0000 To: kde-bugs-dist Subject: [Bug 115442] Crash with KNetwork, after Revision 475735 Message-Id: <20051031211440.18388.qmail () ktown ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-bugs-dist&m=113079328832255 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is. http://bugs.kde.org/show_bug.cgi?id=115442 joris.guisson gmail com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |FIXED ------- Additional Comments From joris.guisson gmail com 2005-10-31 22:14 ------- SVN commit 476208 by guisson: Changes : - Fixed 115442 - We no longer hammer the tracker to continuously after the first 5 failed attempts, we use a 30 seconds delay. BUG: 115442 M +1 -0 httptracker.cpp M +1 -1 serverauthenticate.cpp M +47 -6 tracker.cpp M +6 -1 tracker.h M +1 -0 udptracker.cpp --- trunk/extragear/network/ktorrent/libktorrent/torrent/httptracker.cpp #476207:476208 @ -129,6 +129,7 @ } } delete n; + updateOK(); } void HTTPTracker::doRequest(const KURL & u) --- trunk/extragear/network/ktorrent/libktorrent/torrent/serverauthenticate.cpp #476207:476208 @ -54,7 +54,7 @ finished = true; if (!succes) { - delete sock; + sock->deleteLater(); sock = 0; } timer.stop(); --- trunk/extragear/network/ktorrent/libktorrent/torrent/tracker.cpp #476207:476208 @ -32,7 +32,10 @ peer_id = id; interval = 120; seeders = leechers = 0; + num_failed_attempts = 0; connect(&update_timer,SIGNAL(timeout()),this,SLOT(onTimeout())); + connect(&error_update_timer,SIGNAL(timeout()),this,SLOT(onErrorTimeout())); + error_mode = false; } @ -62,15 +65,43 @ void Tracker::onTimeout() { - event = QString::null; - doRequest(tor->getTrackerURL(true)); + if (!error_mode) + { + event = QString::null; + doRequest(tor->getTrackerURL(true)); + time_of_last_update = GetCurrentTime(); + } + } + + void Tracker::onErrorTimeout() + { + doRequest(tor->getTrackerURL(false)); time_of_last_update = GetCurrentTime(); } + void Tracker::updateOK() + { + error_mode = false; + num_failed_attempts = 0; + error_update_timer.stop(); + } + void Tracker::handleError() { if (event != "stopped") - doRequest(tor->getTrackerURL(true)); + { + error_mode = true; + num_failed_attempts++; + // first try 5 times in a row + // after 5 attempts switch to a 30 second delay + if (num_failed_attempts < 5) + { + doRequest(tor->getTrackerURL(false)); + time_of_last_update = GetCurrentTime(); + } + else + error_update_timer.start(30*1000,true); + } } void Tracker::manualUpdate() @ -88,10 +119,20 @ Uint32 Tracker::getTimeToNextUpdate() const { Uint32 s = (GetCurrentTime() - time_of_last_update) / 1000; - if (s > interval) - return 0; + if (error_mode) + { + if (s > 30) + return 0; + else + return 30 - s; + } else - return interval - s; + { + if (s > interval) + return 0; + else + return interval - s; + } } } --- trunk/extragear/network/ktorrent/libktorrent/torrent/tracker.h #476207:476208 @ -128,6 +128,9 @ private slots: void onTimeout(); + void onErrorTimeout(); + protected: + void updateOK(); protected: SHA1Hash info_hash; @ -136,8 +139,10 @ QString event; Uint32 interval; kt::TorrentInterface* tor; - QTimer update_timer; + QTimer update_timer,error_update_timer; Uint32 time_of_last_update; + Uint32 num_failed_attempts; + bool error_mode; }; } --- trunk/extragear/network/ktorrent/libktorrent/torrent/udptracker.cpp #476207:476208 @ -213,6 +213,7 @ i++; } ppeers.clear(); + updateOK(); }