Jordan Lee [Thu, 12 May 2011 06:43:40 +0000 (06:43 +0000)]
(trunk libT) fix magnet link crash in peer-msgs.c's updateDesiredRequestCount() reported by quinx in the forums.
In some odd cases (such as if unchoked without having shown interest), the code could dividing a number by the torrent's block size without checking to see if the torrent had its metadata yet. This caused a division by zero because a magnet torrent's blocksize is unset until the metadata is downloaded.
Jordan Lee [Tue, 10 May 2011 04:46:44 +0000 (04:46 +0000)]
(trunk libT) CPU improvement in torrent.c's torrentInit()
Add the new torrent to the session's torrent list by prepending it instead of appending it. That way we don't have to walk the list in order to add it. tr_session.torrentList is an unordered list, so there's no real difference between prepending and appending.
Jordan Lee [Tue, 10 May 2011 03:50:54 +0000 (03:50 +0000)]
(trunk libT) CPU optimization in peer-mgr.c's rechokeDownloads()
Instead of recalculating interesting pieces for each peer we loop through, calculate them just once into a bitfield and then reuse that bitfield inside the loop.
Jordan Lee [Tue, 10 May 2011 01:51:12 +0000 (01:51 +0000)]
(trunk libT) CPU improvement in peer-mgr.c's getPeerCandidates()
getPeerCandiates() used to read through all the torrents to determine the global peer connections, and then again to determine the global peer candidates. Now this is done in one loop instead of two.
Jordan Lee [Mon, 9 May 2011 04:16:49 +0000 (04:16 +0000)]
(trunk libT) CPU optimization in tr_bandwidthClamp().
Don't call tr_time_msec() if it's not necessary. This was one of the top CPU sinks in profiling, so removing it is a nice improvement in cases when it's not necessary, such as when speed limiting is disabled.
Jordan Lee [Wed, 4 May 2011 21:38:01 +0000 (21:38 +0000)]
(trunk libT) #2338 "Add uTP support" -- increase the block bandwidth to 3000 bytes in phase 1 as suggested by jch in comment:120.
The rationale is that by using 3000 bytes we'll send one full-size frame straight away, and leave enough buffered data for the next frame to go out in a timely manner.
Jordan Lee [Sun, 1 May 2011 19:10:34 +0000 (19:10 +0000)]
(trunk libT) the functions tr_peerMsgsSetChoke() and tr_peerMsgsSetInterested() have bool arguments whose types never got switched from "int" to "bool" when "bool" was adopted.
Jordan Lee [Fri, 29 Apr 2011 20:22:11 +0000 (20:22 +0000)]
(trunk gtk) tweak to r12398: because most of the strings in category_filter_model_update() will be duplicates of each other, use g_string_chunk_insert_const() instead of g_string_insert().
Jordan Lee [Thu, 28 Apr 2011 18:40:46 +0000 (18:40 +0000)]
(trunk libT) tr_torrentGetFileMTime(): if the file being looked at is aleady open in fdlimit's file cache, use that cached handle instead of deriving our own.
Jordan Lee [Wed, 27 Apr 2011 21:38:45 +0000 (21:38 +0000)]
(trunk libT) heap pruning: use tr_bencToBuf() instead of tr_bencToStr() when building LTEP messages. This saves us from a handful of unnecessary malloc+memcpy+free calls in each instance where the change is made.
Jordan Lee [Wed, 27 Apr 2011 20:52:07 +0000 (20:52 +0000)]
(trunk libT) heap pruning: using the same mechanism as in r12388, avoid an unnecessary malloc+memcpy+free when building the URL for a webseed download request
Jordan Lee [Wed, 27 Apr 2011 20:50:43 +0000 (20:50 +0000)]
(trunk libT) heap pruning: using the same mechanism as in r12388, avoid an unnecessary malloc+memcpy+free when TR_CURL_VERBOSE is logging HTTP messages
Jordan Lee [Wed, 27 Apr 2011 20:41:47 +0000 (20:41 +0000)]
(trunk libT) heap pruning: avoid unnecessary malloc+memcpy+frees in announcer.
1. when creating announce URLs in announcer-http.c
2. when creating scrape URLs in announcer-http.c
3. when deep-logging what announces are in a torrent's queue in announcer.c
Jordan Lee [Wed, 27 Apr 2011 05:29:05 +0000 (05:29 +0000)]
(trunk libT) #4209 "Shortcut UDP tracker test" -- prioritize the UDP handler functions based on frequency (uTP, DHT, UTP tracker) as outlined by jch in comment:5. Also, don't call the uTP or DHT handlers when uTP or DHT is disabled in the system preferences.
To avoid the function call overhead described by jch, instead of calling tr_sessionIsUTPEnabled() and tr_sessionIsDHTEnabled(), we test for WITH_UTP to be defined and test the tr_session.isUTPEnabled and tr_session.isDHTEnabled flags directly.
Jordan Lee [Wed, 27 Apr 2011 05:03:10 +0000 (05:03 +0000)]
(trunk libT) #4209 "Shortcut UDP tracker test" -- the goal of #4209 is to minimize the cost of the UDP event callback function, so apply the heap pruning eye to that by removing an unnecessary malloc/free call there.
Previously we allocated a 4096 character buffer each time; now we allocate it on the stack. It seems all the distros and OS flavors that Transmission runs on have multi-MB default stack sizes, so a hardwired 4K array should be safe.
Jordan Lee [Tue, 19 Apr 2011 19:22:55 +0000 (19:22 +0000)]
(trunk) revert r12372 based on feedback from er13: "Many embedded systems use uClibc++ (and not the gcc' libstdc++) as an implementation of Standard C++ Library. r12372 breaks the compilation of transmission for such systems."
Jordan Lee [Tue, 19 Apr 2011 15:23:04 +0000 (15:23 +0000)]
(trunk libt) #4164 "__FD_SETSIZE impact on open-file-limit and peer-limit-global" -- commit patch by romanr to take FD_SETSIZE into account before calling setrlimit()
Jordan Lee [Tue, 19 Apr 2011 14:40:46 +0000 (14:40 +0000)]
(trunk) fix "__gxx_personality_v0" when compiling Transmission on some versions of gcc/g++
The problem is coming from gcc getting confused by having a C program (Transmission) link against a C++ library (libutp). In gcc, C++ code has an implicit dependency on libstdc++ for the __gxx_personality_v0 function.
More info @ http://stackoverflow.com/questions/329059/what-is-gxx-personality-v0-for
Jordan Lee [Sun, 17 Apr 2011 05:55:46 +0000 (05:55 +0000)]
(trunk libT) heap and event pruning: don't create evtimers for periodic pex messages if the torrent doesn't allow pex (such as, if it's on a private tracker).
Previously, we unconditionally created the evtimer, and then checked each time to see if pex was allowed.
Jordan Lee [Sat, 16 Apr 2011 22:33:29 +0000 (22:33 +0000)]
(trunk libT) #4165 "__FD_SETSIZE impact on open-file-limit and peer-limit-global" -- add safety guard in the file cache to prevent too many open files.
Instead of calling gtk_combo_box_get_active_iter() on the filterbar's two comboboxes in every periodic update, keep the state information in a local struct and update it when the selection changes. That way the filter code doesn't even need to know about the GtkComboBox or the GtkTreeModel.
Jordan Lee [Wed, 13 Apr 2011 22:00:55 +0000 (22:00 +0000)]
(trunk gtk) more heap pruning: minor GtkTreeModel changes
Use gtk_tree_model_iter_nth_child() instead of gtk_tree_model_get_iter_first() to avoid an unnecessary gtk_tree_path object being created and destroyed. This is a very minor change and I'm not sure how useful it really is, but it doesn't hurt.
Jordan Lee [Wed, 13 Apr 2011 06:18:30 +0000 (06:18 +0000)]
(trunk gtk) more heap pruning:
querying gconf2 each time the curl callack function is called is expensive, so query it once -- then again later, if the proxy settings change -- and remember the values in a local struct.
Jordan Lee [Mon, 11 Apr 2011 19:44:16 +0000 (19:44 +0000)]
(trunk libT) fix 2.30b1 memory corruption bug when editing trackers.
The problem was that the new number of trackers was not being kept and the old count was retained. So if the count changed, tr_torrentTrackers() could return dangling pointers to the caller.
Jordan Lee [Thu, 7 Apr 2011 20:00:26 +0000 (20:00 +0000)]
(trunk libT) use get_next_scrape_time() inside the scrape error handler.
get_next_scrape_time() was introduced in r12297. The rationale is that by rounding all scrape times to their nearest 10th second, they will tend to occur in batches and improve multiscrape.
Jordan Lee [Thu, 7 Apr 2011 19:54:30 +0000 (19:54 +0000)]
(trunk libT) #3931 "'Announce is Queued' but torrent doesn't announce itself to trackers" -- add more debugging information for the next announce interval when an announce error is encountered, as requested by Sardok in comment:70 of #3931