with 1M buffer per uploading file, my hdd was much quiet!!
I think DC++ is a very good P2P software that could be use in a LAN,
Not like INTERNET, a LAN network's speed is too fast, I write a speed
limit on my client, and I Limit the speed at 1M/s, with 5 slots, my HDD
was seek all the time, I think this is too bad for HDD.
Here is the Read Buffer Code, Wish Can be use in later DC++ version.
And anyother can download my modify version to test this function.
// client\File.h
Code: Select all
class BufferedInputStream : public InputStream {
public:
BufferedInputStream(InputStream* aStream, size_t aBufSize = SETTING(BUFFER_SIZE) * 1024) : is(aStream), pos(0), dataSize(0), bufSize(aBufSize), buf(new u_int8_t[bufSize]) { }
virtual ~BufferedInputStream() {
delete is;
delete buf;
}
size_t read(void* rbuf, size_t& len){
u_int8_t* b = (u_int8_t*)rbuf;
size_t l2 = len;
while (l2 > 0){
if (dataSize == 0 || pos >= dataSize){
dataSize = is->read(buf, bufSize);
if (dataSize == 0) return (len - l2);
pos = 0;
}
size_t n = min(dataSize - pos, l2);
memcpy(b, buf + pos, n);
pos += n;
l2 -= n;
b += n;
}
return len;
}
// client\UploadManager.cpp
// Add to the UploadManager::prepareFile(), can locate the code with the extra code.
// Modify based on DC++ 0.4034
Code: Select all
// Read Buffer InputStream
/* Added code start */
{
size_t bufSize = SETTING(BUFFER_SIZE) * 1024;
if ((size - aStartPos) > 10240 && bufSize > 0){
if ((size - aStartPos) < bufSize){
bufSize = size - aStartPos;
}
is = new BufferedInputStream(is, bufSize);
}
}
/* Added code end */
Upload* u = new Upload();
u->setUserConnection(aSource);
u->setFile(is);
u->setSize(size);
u->setStartPos(aStartPos);
u->setFileName(file);
u->setLocalFileName(file);