Jordan Lee [Thu, 31 Mar 2011 04:01:55 +0000 (04:01 +0000)]
(trunk libT) fix ABR detected by clang static analyzer in tr_torrentStat.
When copying a value to s->errorString, it used memcpy(a,b,sizeof(a)) where sizeof(a) was larger than sizeof(b). Fixed by replacing the memcpy() call with tr_strlcpy().
Jordan Lee [Wed, 30 Mar 2011 23:26:00 +0000 (23:26 +0000)]
(trunk libT) #4153 "Protect against non-monotonic time in libutp" -- move UTP_GetMilliseconds() and UTP_GetMicroseconds() outside of the if-not-windows ifdef section. Based on feedback from rb07 in ticket comment 5
Protect against monotonic time being non-monotonic.
Within utp.cpp, there's a bunch of assertions that will cause us
to crash if monotonic time isn't. While I have no idea about Windows,
under Unix we use real time instead of monotonic time if POSIX clocks
are not available, and real time can be stepped backwards. Since the
protection is cheap, we perform it on all platforms.
Jordan Lee [Tue, 29 Mar 2011 15:23:54 +0000 (15:23 +0000)]
(trunk libT) don't cache unininteresting peer addresses between sessions
For example, if we're both seeds, or if the peer is not connectible, don't bother caching it for the next session. If it's still alive, we'll find it up through DHT or tracker announces next time around. As with r12253, this commit's intention is to reduce the number of unproductive peer_atoms that we waste time trying to connect to.
Jordan Lee [Tue, 29 Mar 2011 15:18:25 +0000 (15:18 +0000)]
(trunk libT) better scrape management on private trackers.
If a private tracker scrape says that there are no downloaders in the swarm, mark all the peers in the private swarm as seeds. This can greatly reduce unnecessary overhead on large seedboxes. We don't do this same trick on public torrents, since a public tracker won't know of all the peers.
Jordan Lee [Tue, 29 Mar 2011 01:17:18 +0000 (01:17 +0000)]
(trunk libT) more completion and bitfield cleanup: (1) fix regression in tr_cpSizeWhenDone() reported by Waldorf, (2) make simple one-liner functions inlined
Jordan Lee [Mon, 28 Mar 2011 16:46:57 +0000 (16:46 +0000)]
(trunk mac) delete bitset.[ch] from the xcode file. No, I don't know what I'm doing, but what's the worst that could happen, it could break the build... :)
Jordan Lee [Mon, 28 Mar 2011 16:31:05 +0000 (16:31 +0000)]
(trunk libT) break the mac build and introduce new crashes.
This is partially to address #4145 "Downloads stuck at 100%" by refactoring the bitset, bitfield, and tr_completion; however, the ripple effect is larger than usual so things may get worse in the short term before getting better.
livings124: to fix the mac build, remove bitset.[ch] from xcode
Jordan Lee [Thu, 24 Mar 2011 22:57:39 +0000 (22:57 +0000)]
(trunk libT) copyediting: remove a bunch of seemingly-unneeded network headers in net.[ch].
I'm less certain that these are unneeded because networking APIs seem to have more variation between platforms, but it's better to remove the cruft and then add back whatever headers $PLATFORM users complain about, than to not remove the cruft at all...
Jordan Lee [Sun, 20 Mar 2011 15:28:41 +0000 (15:28 +0000)]
(trunk libT) #117 "UDP tracker protocol support" -- (1) fix connection attempt retries after a failed connection attempt. (2) extract method from tau_tracker_upkeep() for clarity: tau_tracker_send_reqs() and tau_tracker_timeout_reqs()
refactor the timeout/request code a bit.
Jordan Lee [Thu, 17 Mar 2011 18:51:31 +0000 (18:51 +0000)]
(trunk libT) better shutdown management of libutp and UDP trackers in tr_sessionClose().
This is a little overlapping since the utp code can be closed more-or-less immediately, but the udp manager needs to stay open in order to process the udp tracker connection requests before sending out event=stopped. Moreover DNS resolver can be shut down after the UDP tracker is shutdown.
Jordan Lee [Thu, 17 Mar 2011 13:16:23 +0000 (13:16 +0000)]
(trunk libT) as a followup to r12182, move LPD's periodic upkeep timer into the tr-lpd.c module where it can be started & stopped with the pre-existing tr_lpdInit() and tr_lpdUninit() functions.
Jordan Lee [Thu, 17 Mar 2011 12:45:29 +0000 (12:45 +0000)]
(trunk libT) move tr_lpdAnnounceMore() out of the announcer module
We can stop local peer discovery immediately during shutdown, but need to leave the announcer running for the event=stopped messages. So it doesn't make sense to keep them on the same periodic timer.
Jordan Lee [Thu, 17 Mar 2011 12:34:43 +0000 (12:34 +0000)]
(trunk libT) move tr_dhtUpkeep() out of the announcer module
During shutdown, we can stop DHT almost immediately, but need to leave the announcer running for the DHT tracker event=stopped messages. So it doesn't make sense to keep them on the same periodic timer.
Jordan Lee [Thu, 17 Mar 2011 04:16:19 +0000 (04:16 +0000)]
(trunk libT) #117 "UDP tracker protocol suppoort" -- in case the tracker gives an error message in response to a connection response, store the error message in the scrape/announce response structs' errmsg fields.