Skip to content

Commit 3506fc9

Browse files
committed
* Fixed a buffer overflow when writting to the output buffer. This
would in some rare occasions cause memory to be corrupted. leading to a crash. * Added option for setting the http proxy and proccess's umask. * Save the total uploaded for downloads between sessions. * Moved from sigc++ to my own lightweight slot class for the task scheduler. This saves some 5-600kb when compiled with debugging symbols, 1-200kb without. git-svn-id: svn://rakshasa.no/libtorrent/trunk/libtorrent@605 e378c898-3ddf-0310-93e7-cc216c733640
1 parent 2a18ba4 commit 3506fc9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+300
-235
lines changed

BUGS

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
FIXME LATER:
22

3-
Caught exception: "DownloadWrapper::resume_save() called with wrong state"
4-
5-
6-
"Connection read fd(40) state(5) "PeerConnectionBase::read_chunk() tried to read a piece but is not in throttle list""
3+
Caught exception from libtorrent: Connection write fd(68,0,6) "ProtocolBuffer tried to write beyond scope of the buffer"

Makefile.am

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ EXTRA_DIST= \
1313
rak/algorithm.h \
1414
rak/error_number.h \
1515
rak/functional.h \
16+
rak/functional_fun.h \
1617
rak/ranges.h \
1718
rak/string_manip.h \
1819
rak/timer.h \

TODO

+3-92
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ Display leechers/seeders.
1313
Make sure storage error is correctly displayed, rather than being
1414
hidden.
1515

16-
Make the vfat workaround configurable.
16+
Make the vfat workaround configurable. Also add note to the wiki.
1717

18-
* Move block download done to DownloadWrapper.
18+
Different min peers for seeding and leeching modes?
1919

20-
* Move finished delay signal out into downloadwrapper.
20+
Store data on which side inititalized the connection.
2121

2222

2323
=== For the next API change ===
@@ -35,13 +35,6 @@ those regions.
3535
===
3636

3737

38-
=== Delegator refactoring ===
39-
40-
Seperate out DelegatorSelect, rewrite it and use slots.
41-
42-
======
43-
44-
4538
=== Hash Resume save ===
4639

4740
[R] could you add a trigger for Download::hash_resume_save when a torrent
@@ -104,35 +97,17 @@ function that chokes all and doesn't allow new unchokes.
10497

10598
Move download initializiation stuff into Manager.
10699

107-
Replace download_remove's info_hash thingie with Download.
108-
109-
Use partial sort, or nth_element.
110-
111100
Rename most things to remote/local or something. up/down is too
112101
confusing. Atleast add it to some of the function names.
113102

114-
Rewrite throttle code, consider not updating when unlimited. Do an
115-
update when putting them into unlimited mode.
116-
117-
Optimize interested, seperate return values for requesting where we
118-
are still interested downloading from others and when we're not
119-
interested anymore.
120-
121103
Would be nice to refactor requester, it should own the bitfield in some way?
122104

123-
Wait when receiving resource tmp unavailable. Currently need to close
124-
the connection.
125-
126105
delegator's priorities are reset on DownloadMain::open? Make the
127106
priority thing work right, don't use a seperate function for updating
128107
them.
129108

130109
Consider asking for read-ahead for fast peers.
131110

132-
File priority might not like sequential requesting.
133-
134-
Cache the number of unchoked peers.
135-
136111
Unaligned 58.6.0.92 0.0
137112

138113
Do move of session torrent so we don't end up with incomplete torrent
@@ -144,20 +119,11 @@ they don't give rw perm or resize?
144119
Clearer display of which torrents are stopped, make it into a seperate
145120
column.
146121

147-
Move stuff into rak.
148-
149-
Slot in torrent/Peer for incoming, so we can use SocketAddress
150-
internally?
151-
152122
Re-add slot for removing incoming connections from available list? If
153123
so, remove the check in connect_peers.
154124

155125
Move endgame detection to delegator?
156126

157-
Make sure rtorrent's http downloading times out.
158-
159-
Different min peers for seeding and leeching modes?
160-
161127
Rename TrackerControl?
162128

163129
Remove get_ for certain class of accesses, also make them pointers to
@@ -198,11 +164,6 @@ Add filter for ip address, and peer id. These must be seperate as ip
198164
happens before handshake, but peer id is done after handshake or
199165
before connecting.
200166

201-
Make the tries adjuster into a setting.
202-
203-
Doesn't force in some cases when the system is overloaded and you got
204-
small hash chunks.
205-
206167
Fix hash checking slowness on overworked boxens. Possibly mark the
207168
mmap'ed area as sequential. Add options to the man page.
208169

@@ -219,67 +180,24 @@ downloads at all times.
219180
Use a seperate function for checking the hash status when doing
220181
download starts.
221182

222-
Possibly do sync before/after checking hash. Don't sync complete
223-
chunks as they were synced at the time of hash checking? Read the list
224-
of dirty chunks from the delegator. Need to fix the problem of corrupt
225-
downloads due to lack of diskspace.
226-
227-
Ponder race condition on lazy hash checking, do new data get written
228-
before we start checking?
229-
230-
The handling of hash fails isn't good enough...
231-
232-
Directory validation needs to be lazy?
233-
234-
Disable read/write_chunk exceptions.
235-
236-
Don't allow many handshakes from the same ip?
237-
238-
Create a std::list'ish thing that contains the current downloads, and
239-
expose it to the client. Will make DownloadManager 'redundant'. Don't fix?
240-
241-
242183

243184
*** STUFF I MIGHT DO SOME DAY ***
244185

245-
SMALL TODO STUFF I HAVEN'T BOTHERED DOING YET:
246-
247186
After 25 seconds, choke a peer if no requests have been received?
248187

249-
Add average, max and total to rates. Will this be controlled by
250-
choke/unchoke?
251-
252188
Add a snub factor. The more you upload without getting back, the
253189
higher it goes. Add a start buffer.
254190

255191
Add config for how often we unchoke unknown peers vs good uploaders
256192

257-
Each throttle can have it's own rules to decide the priority it gets.
258-
259-
Switch to a proper type for file offset/length and chunk length. A
260-
proper type for chunk index.
261-
262193
std::isalpha in escape string
263194

264-
Store data on which side inititalized the connection.
265-
266195
torrent::Http::call_cleanup to delete the factory created object?
267196

268197
If we get conflicting prot flags in get_chunk, we might go into cycle
269198
of re-allocating. Do a union instead.
270199

271200

272-
LONG TERM:
273-
274-
Make a collection of stuff in utils that can be shared between apps.
275-
276-
277-
TIMER RELATED
278-
279-
Throttle update needs to be off when no throttle is on. Make sure it
280-
doesn't bork with using up allocated bytes.
281-
282-
283201
DELEGATOR STUFF
284202

285203
Proper canceling of pieces in sendHave, unless only one can download a
@@ -292,10 +210,6 @@ Don't be so aggressive at selecting stalled pieces.
292210

293211
AFTER API REDESIGN:
294212

295-
Add the option to not throw non-critical exceptions. This lets the
296-
client be ignorant of errors while creating stuff. (Make some kind of
297-
C friendly layer ontop)
298-
299213
Consider ways of optimizing bitfield memory usage. A bitfield with all
300214
set shouldn't change ever... And do a count on number of set bits?
301215

@@ -326,7 +240,4 @@ disallow for open torrents?
326240

327241
Move mkdir stuff out of Path?
328242

329-
Cleanup HashQueue, seperate out nodes etc. * Make it a private list.
330-
* Don't pass Chunk in SlotDone.
331-
332243
Lock file in session directory.

rak/functional.h

+36-36
Original file line numberDiff line numberDiff line change
@@ -349,12 +349,12 @@ bind2nd(const Operation& op, const Type& val) {
349349
// of using a seperate functor for that.
350350

351351
template <typename Object, typename Ret>
352-
class mem_fn0 {
352+
class mem_fun0 {
353353
public:
354354
typedef Ret (Object::*Function)();
355355

356-
mem_fn0() : m_object(NULL) {}
357-
mem_fn0(Object* o, Function f) : m_object(o), m_function(f) {}
356+
mem_fun0() : m_object(NULL) {}
357+
mem_fun0(Object* o, Function f) : m_object(o), m_function(f) {}
358358

359359
bool is_valid() const { return m_object; }
360360

@@ -366,12 +366,12 @@ class mem_fn0 {
366366
};
367367

368368
template <typename Object, typename Ret>
369-
class const_mem_fn0 {
369+
class const_mem_fun0 {
370370
public:
371371
typedef Ret (Object::*Function)() const;
372372

373-
const_mem_fn0() : m_object(NULL) {}
374-
const_mem_fn0(Object* o, Function f) : m_object(o), m_function(f) {}
373+
const_mem_fun0() : m_object(NULL) {}
374+
const_mem_fun0(Object* o, Function f) : m_object(o), m_function(f) {}
375375

376376
bool is_valid() const { return m_object; }
377377

@@ -383,12 +383,12 @@ class const_mem_fn0 {
383383
};
384384

385385
template <typename Object, typename Ret, typename Arg1>
386-
class mem_fn1 {
386+
class mem_fun1 {
387387
public:
388388
typedef Ret (Object::*Function)(Arg1);
389389

390-
mem_fn1() : m_object(NULL) {}
391-
mem_fn1(Object* o, Function f) : m_object(o), m_function(f) {}
390+
mem_fun1() : m_object(NULL) {}
391+
mem_fun1(Object* o, Function f) : m_object(o), m_function(f) {}
392392

393393
bool is_valid() const { return m_object; }
394394

@@ -400,12 +400,12 @@ class mem_fn1 {
400400
};
401401

402402
template <typename Object, typename Ret, typename Arg1>
403-
class const_mem_fn1 {
403+
class const_mem_fun1 {
404404
public:
405405
typedef Ret (Object::*Function)(Arg1) const;
406406

407-
const_mem_fn1() : m_object(NULL) {}
408-
const_mem_fn1(Object* o, Function f) : m_object(o), m_function(f) {}
407+
const_mem_fun1() : m_object(NULL) {}
408+
const_mem_fun1(Object* o, Function f) : m_object(o), m_function(f) {}
409409

410410
bool is_valid() const { return m_object; }
411411

@@ -417,12 +417,12 @@ class const_mem_fn1 {
417417
};
418418

419419
template <typename Object, typename Ret, typename Arg1, typename Arg2>
420-
class mem_fn2 : public std::binary_function<Arg1, Arg2, Ret> {
420+
class mem_fun2 : public std::binary_function<Arg1, Arg2, Ret> {
421421
public:
422422
typedef Ret (Object::*Function)(Arg1, Arg2);
423423

424-
mem_fn2() : m_object(NULL) {}
425-
mem_fn2(Object* o, Function f) : m_object(o), m_function(f) {}
424+
mem_fun2() : m_object(NULL) {}
425+
mem_fun2(Object* o, Function f) : m_object(o), m_function(f) {}
426426

427427
bool is_valid() const { return m_object; }
428428

@@ -434,12 +434,12 @@ class mem_fn2 : public std::binary_function<Arg1, Arg2, Ret> {
434434
};
435435

436436
template <typename Object, typename Ret, typename Arg1, typename Arg2, typename Arg3>
437-
class mem_fn3 {
437+
class mem_fun3 {
438438
public:
439439
typedef Ret (Object::*Function)(Arg1, Arg2, Arg3);
440440

441-
mem_fn3() : m_object(NULL) {}
442-
mem_fn3(Object* o, Function f) : m_object(o), m_function(f) {}
441+
mem_fun3() : m_object(NULL) {}
442+
mem_fun3(Object* o, Function f) : m_object(o), m_function(f) {}
443443

444444
bool is_valid() const { return m_object; }
445445

@@ -451,39 +451,39 @@ class mem_fn3 {
451451
};
452452

453453
template <typename Object, typename Ret>
454-
inline mem_fn0<Object, Ret>
455-
make_mem_fn(Object* o, Ret (Object::*f)()) {
456-
return mem_fn0<Object, Ret>(o, f);
454+
inline mem_fun0<Object, Ret>
455+
make_mem_fun(Object* o, Ret (Object::*f)()) {
456+
return mem_fun0<Object, Ret>(o, f);
457457
}
458458

459459
template <typename Object, typename Ret>
460-
inline const_mem_fn0<Object, Ret>
461-
make_mem_fn(Object* o, Ret (Object::*f)() const) {
462-
return const_mem_fn0<Object, Ret>(o, f);
460+
inline const_mem_fun0<Object, Ret>
461+
make_mem_fun(Object* o, Ret (Object::*f)() const) {
462+
return const_mem_fun0<Object, Ret>(o, f);
463463
}
464464

465465
template <typename Object, typename Ret, typename Arg1>
466-
inline mem_fn1<Object, Ret, Arg1>
467-
make_mem_fn(Object* o, Ret (Object::*f)(Arg1)) {
468-
return mem_fn1<Object, Ret, Arg1>(o, f);
466+
inline mem_fun1<Object, Ret, Arg1>
467+
make_mem_fun(Object* o, Ret (Object::*f)(Arg1)) {
468+
return mem_fun1<Object, Ret, Arg1>(o, f);
469469
}
470470

471471
template <typename Object, typename Ret, typename Arg1>
472-
inline const_mem_fn1<Object, Ret, Arg1>
473-
make_mem_fn(Object* o, Ret (Object::*f)(Arg1) const) {
474-
return const_mem_fn1<Object, Ret, Arg1>(o, f);
472+
inline const_mem_fun1<Object, Ret, Arg1>
473+
make_mem_fun(Object* o, Ret (Object::*f)(Arg1) const) {
474+
return const_mem_fun1<Object, Ret, Arg1>(o, f);
475475
}
476476

477477
template <typename Object, typename Ret, typename Arg1, typename Arg2>
478-
inline mem_fn2<Object, Ret, Arg1, Arg2>
479-
make_mem_fn(Object* o, Ret (Object::*f)(Arg1, Arg2)) {
480-
return mem_fn2<Object, Ret, Arg1, Arg2>(o, f);
478+
inline mem_fun2<Object, Ret, Arg1, Arg2>
479+
make_mem_fun(Object* o, Ret (Object::*f)(Arg1, Arg2)) {
480+
return mem_fun2<Object, Ret, Arg1, Arg2>(o, f);
481481
}
482482

483483
template <typename Object, typename Ret, typename Arg1, typename Arg2, typename Arg3>
484-
inline mem_fn3<Object, Ret, Arg1, Arg2, Arg3>
485-
make_mem_fn(Object* o, Ret (Object::*f)(Arg1, Arg2, Arg3)) {
486-
return mem_fn3<Object, Ret, Arg1, Arg2, Arg3>(o, f);
484+
inline mem_fun3<Object, Ret, Arg1, Arg2, Arg3>
485+
make_mem_fun(Object* o, Ret (Object::*f)(Arg1, Arg2, Arg3)) {
486+
return mem_fun3<Object, Ret, Arg1, Arg2, Arg3>(o, f);
487487
}
488488

489489
}

0 commit comments

Comments
 (0)