Bug 131246 - Bandwidth Scheduler not adjusting speeds when time restrictions crossed
Summary: Bandwidth Scheduler not adjusting speeds when time restrictions crossed
Status: RESOLVED FIXED
Alias: None
Product: ktorrent
Classification: Applications
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Joris Guisson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-07-23 17:48 UTC by Colin Pinkney
Modified: 2006-07-24 21:02 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Colin Pinkney 2006-07-23 17:48:40 UTC
Version:           2.0rc1 (using KDE KDE 3.5.2)
Installed from:    Ubuntu Packages
OS:                Linux

In v2.0rc1 I have the bandwidth scheduler plugin set so that between the hours of 4pm and midnight my download and upload speeds are restricted to 30kbps and 15kbps respectively (due to ISP having peak time download/upload limits). Outside of these times, the scheduler has no restrictions, but in the ktorrent preferences I have set the global max download and upload speeds as 200kbps and 30kbps respectively.

The problem I have is when it is downloading/uploading and the time changes to 4pm, the scheduler does not seem to automatically change the speed restrictions to 30/15kbps and similarly when going past midnight the restrictions do not change back to 200/30kbps.

I have left it running for 10 minutes after 4pm, but it was still downloading at 200kbps and uploading at 30kbps instead of the scheduler restricted speeds. If I open the scheduler config window and click OK without changing anything, it updates the speed restrictions, but the idea of the scheduler is for unattended changes to the speeds.

I have just done a clean install of Kubuntu Dapper and downloaded the Kubuntu i386 deb v2.0rc1 package from the ktorrent.org download page. Other than this issue it has been rock solid, nice work! I just need this scheduling to work to replace Azureus *spit*.
Comment 1 Joris Guisson 2006-07-24 20:10:37 UTC
It seems that the timer triggers 1 second before the hour changes, so if you set your schedule to 4 PM, the timer fires at 3:59 and 59 seconds, so the limits for the previous hour are chosen.

It seems the timer needs some tweaking.
Comment 2 Joris Guisson 2006-07-24 21:02:16 UTC
SVN commit 565904 by guisson:

Scheduler timer now fires after the hour so that the correct up and down caps are chosen.

BUG: 131246



 M  +16 -12    bwscheduler.cpp  
 M  +2 -1      schedulerplugin.cpp  


--- trunk/extragear/network/ktorrent/plugins/scheduler/bwscheduler.cpp #565903:565904
@@ -172,39 +172,43 @@
 		{
 			case CAT_NORMAL:
 				Out(SYS_SCD|LOG_NOTICE) << prefix << "Switching to NORMAL category" << endl;
-
+				Out(SYS_SCD|LOG_NOTICE) << prefix << QString("%1 Up, %2 Down")
+						.arg(m_core->getMaxUploadSpeed()).arg(m_core->getMaxDownloadSpeed()) << endl;
 				if(!m_core)
 					break;
 				m_core->setPausedState(false);
-				net::SocketMonitor::setDownloadCap(1024 * m_core->getMaxDownloadSpeed());
-				net::SocketMonitor::setUploadCap(1024 * m_core->getMaxUploadSpeed());
+				net::SocketMonitor::setDownloadCap(1000 * m_core->getMaxDownloadSpeed());
+				net::SocketMonitor::setUploadCap(1000 * m_core->getMaxUploadSpeed());
 				break;
 			case CAT_FIRST:
 				Out(SYS_SCD|LOG_NOTICE) << prefix << "Switching to FIRST category" << endl;
-
+				Out(SYS_SCD|LOG_NOTICE) << prefix << QString("%1 Up, %2 Down")
+						.arg(m_schedule.getUpload(0)).arg(m_schedule.getDownload(0)) << endl;
 				if(!m_core)
 					break;
 				m_core->setPausedState(false);
-				net::SocketMonitor::setDownloadCap(1024 * m_schedule.getDownload(0));
-				net::SocketMonitor::setUploadCap(1024 * m_schedule.getUpload(0));
+				net::SocketMonitor::setDownloadCap(1000 * m_schedule.getDownload(0));
+				net::SocketMonitor::setUploadCap(1000 * m_schedule.getUpload(0));
 				break;
 			case CAT_SECOND:
 				Out(SYS_SCD|LOG_NOTICE) << prefix << "Switching to SECOND category" << endl;
-
+				Out(SYS_SCD|LOG_NOTICE) << prefix << QString("%1 Up, %2 Down")
+						.arg(m_schedule.getUpload(1)).arg(m_schedule.getDownload(1)) << endl;
 				if(!m_core)
 					break;
 				m_core->setPausedState(false);
-				net::SocketMonitor::setDownloadCap(1024 * m_schedule.getDownload(1));
-				net::SocketMonitor::setUploadCap(1024 * m_schedule.getUpload(1));
+				net::SocketMonitor::setDownloadCap(1000 * m_schedule.getDownload(1));
+				net::SocketMonitor::setUploadCap(1000 * m_schedule.getUpload(1));
 				break;
 			case CAT_THIRD:
 				Out(SYS_SCD|LOG_NOTICE) << prefix << "Switching to THIRD category" << endl;
-
+				Out(SYS_SCD|LOG_NOTICE) << prefix << QString("%1 Up, %2 Down")
+						.arg(m_schedule.getUpload(2)).arg(m_schedule.getDownload(2)) << endl;
 				if(!m_core)
 					break;
 				m_core->setPausedState(false);
-				net::SocketMonitor::setDownloadCap(1024 * m_schedule.getDownload(2));
-				net::SocketMonitor::setUploadCap(1024 * m_schedule.getUpload(2));
+				net::SocketMonitor::setDownloadCap(1000 * m_schedule.getDownload(2));
+				net::SocketMonitor::setUploadCap(1000 * m_schedule.getUpload(2));
 				break;
 			case CAT_OFF:
 				Out(SYS_SCD|LOG_NOTICE) << prefix << "Switching to OFF" << endl;
--- trunk/extragear/network/ktorrent/plugins/scheduler/schedulerplugin.cpp #565903:565904
@@ -86,7 +86,8 @@
 		
 		QDateTime round(hour.date(), t);
 		
-		int secs_to = now.secsTo(round);
+		// add a 5 second safety margin (BUG: 131246)
+		int secs_to = now.secsTo(round) + 5;
 		
 		m_timer.start(secs_to*1000);