Dropping slow users

Problems compiling? Don't understand the source code? Don't know how to code your feature? Post here.

Moderator: Moderators

Locked
xhost+
Posts: 19
Joined: 2004-01-22 18:01
Location: in.the.middle.of.nowhere

Dropping slow users

Post by xhost+ » 2004-01-22 18:14

Hi all,

This is my first post here, so don't start a flame war if I'm off topic.
This is just to let you know that I have added an option to DC++ 0.305 (but should be easy to port on .306) which will automatically remove a user from queue if its download speed stalls below a settable limit for a settable period.
I've add this as a property of a QueueItem which allows you to keep download in the queue the old way if there's not a lot of sources for example.
I've tested for over 24 continuous hours and I found it rather efficient.
If you want to give it a try, just let me know.

I found a bug in my implementation however for I drop the user by a call to QueueItem::removeSource within DownloadManager::onhandledata. Problem is if the download really drops to 0, onhandledata is not called ('cause there's no data to handle) and the user is not dropped. Any idea ?

xhost+

psf8500
Posts: 23
Joined: 2003-03-04 18:51
Contact:

Post by psf8500 » 2004-01-22 19:13

Here's a bit of code from DC++k 0.251 which may help:

Code: Select all

void MainFrame::onDownloadTick(const Download::List& dl) {
	vector<StringListInfo*>* v = new vector<StringListInfo*>();
	v->reserve(dl.size());

	{
		Lock l(cs);
		for(Download::List::const_iterator j = dl.begin(); j != dl.end(); ++j) {
			Download* d = *j;
			char* buf = new char[STRING(DOWNLOADED_LEFT).size() + 32];
			sprintf(buf, CSTRING(DOWNLOADED_LEFT), Util::formatBytes(d->getPos()).c_str(), 
				(double)d->getPos()*100.0/(double)d->getSize(), Util::formatBytes(d->getRunningAverage()).c_str(), Util::formatSeconds(d->getSecondsLeft()).c_str());
			
			ConnectionQueueItem* aCqi = d->getUserConnection()->getCQI();
			ItemInfo* ii = transferItems[aCqi];
			ii->pos = d->getPos();

			StringListInfo* i = new StringListInfo((LPARAM)ii);
			i->columns[COLUMN_STATUS] = buf;
			delete[] buf;
			
			v->push_back(i);
// DCPP_EXTENDER BEGINS
			if(d->getRunningAverage() <= 0)
			{
				d->getUserConnection()->reconnect();
			}
// DCPP_EXTENDER ENDS
		}
	}
	
	PostMessage(WM_SPEAKER, SET_TEXTS, (LPARAM)v);
}
It reconnects if a download drops to 0 bytes. but i guess you could disconnect from here and also remove the queue item aswell.

Locked