Commit Graph

251 Commits

Author SHA1 Message Date
Matt Joiner d5682e9cd0 Change a bunch of Stringer and status stuff
Cumulative interest time, download rate per connection, request low and high waters, peer extension bytes
2018-02-05 17:47:47 +11:00
Matt Joiner 93e8d9bfaa Use stringer to generate peer_protocol.MessageType strings 2018-02-05 15:30:35 +11:00
Matt Joiner 20316e5af4 Support AllowedFast and enable fast extension 2018-02-05 00:18:38 +11:00
Matt Joiner b2860bad21 Fix the connection completed string if peer sent HaveAll 2018-02-04 22:43:28 +11:00
Matt Joiner 2e36ad19d9 Finish mainReadLoop on Torrent closed 2018-02-04 19:14:46 +11:00
Matt Joiner 44e44637bf TODOs and comments 2018-02-04 19:14:07 +11:00
Matt Joiner e0c2265cb0 Support sending HaveAll 2018-02-04 19:10:25 +11:00
Matt Joiner 64d13d86a6 Tickle sleeping writers when closing connections
This prevents them sleeping for an indefinite period (although something seemed to wake them eventually).
2018-02-03 15:44:03 +11:00
Matt Joiner e1ea10fa2d Wasn't recording posted message stats 2018-02-03 15:29:06 +11:00
Matt Joiner efecf88d3c Use flip buffering for connection writing 2018-02-03 15:09:38 +11:00
Matt Joiner 86aabb081c Share the post write buffer with the synchronous one in the connection writer
This should prevent messages posted while generating synchronous messages don't get out of order.
2018-02-03 14:40:03 +11:00
Matt Joiner 9b1a769bef Move extended message handling into its own method 2018-02-03 14:06:10 +11:00
Matt Joiner 738a75bc1c Prepare to support sending reject messages 2018-02-03 13:35:09 +11:00
Matt Joiner f23d097502 Include closed connections in dirtiers 2018-02-03 12:08:16 +11:00
Matt Joiner 5fcb920f96 Use new logging in connection.go 2018-02-03 12:06:52 +11:00
Matt Joiner 9567aa901c Add missing increments to some stats 2018-02-03 11:53:11 +11:00
Matt Joiner 5a4e8cd4c5 Rename and rearrange some conn stats 2018-02-03 00:41:13 +11:00
Matt Joiner 7a95714df2 Factor out connection.onReadRequest 2018-02-02 19:19:14 +11:00
Matt Joiner fe991128ed Rework connection stat reconciliation with Torrent and refactor doppleganger handling 2018-02-02 19:07:20 +11:00
Matt Joiner b0c1f99509 Merge a bunch of stuff into ConnStats and refactor connection.upload 2018-02-02 19:04:56 +11:00
Matt Joiner c9507786f2 Count requested chunk lengths
Have seen some very ridiculous lengths causing data read errors
2018-02-02 16:06:24 +11:00
Matt Joiner 8a43910e2d connection.writer wasn't checking closed state 2018-02-02 13:36:18 +11:00
Matt Joiner 7b037cd024 Missed sendChunk invocation change 2018-02-02 13:34:35 +11:00
Matt Joiner 97ffe39561 Move sendChunk onto connection 2018-02-02 13:26:04 +11:00
Matt Joiner 186c5df3d3 When seeding, connections are not just useful when they're interested
Improves peer selection when seeding is enabled, we're still downloading.
2018-02-01 18:49:53 +11:00
Matt Joiner 2166bf1ec0 Some changes to status output 2018-02-01 18:45:58 +11:00
Matt Joiner 1e9f342a15 Merge piece and chunk iter inputs to nextRequestState
This will allow the iterator to filter chunks for request strategies.
2018-02-01 16:14:13 +11:00
Matt Joiner 3217c5012a Code comments 2018-02-01 14:46:48 +11:00
Matt Joiner 9387e60999 Track concurrent requests across connections
In preparation for some more request strategy options
2018-02-01 14:46:03 +11:00
Matt Joiner ef4c0f1413 Add Torrent.Stats.ConnectedSeeders
Fixes #231
2018-01-29 18:22:21 +11:00
Matt Joiner 52524925d2 Add separate piece priorities, and cache pending pieces
Should fix a bug where prioritizing files is not alone sufficient to trigger downloading.
2018-01-25 17:18:36 +11:00
Matt Joiner 4807d05018 Improve some comments 2018-01-25 17:02:52 +11:00
Matt Joiner ed7e3f6ec0 Make Torrent.pendingPieces a priority bitmap in preparation for #220 2018-01-12 12:24:37 +11:00
Matt Joiner 8eb1a3effe Screen negative pieces
Should fix #228.
2018-01-09 17:26:01 +11:00
Matt Joiner ff6f28f87c Fix a log format string 2018-01-07 19:24:00 +11:00
Matt Joiner e13b0eccbf Make peerID a public type
Wanted it applied to Client Status output
2018-01-06 15:50:45 +11:00
Matt Joiner c44ee5fec4 Use peerID type more, and make its Stringer output nicer 2018-01-06 12:34:31 +11:00
Matt Joiner 8195e8df7b Improve some doc comments 2017-12-29 12:16:05 +11:00
Matt Joiner f408e19a7a Survive panics while writing chunks
Also improve the comment on that code
2017-12-29 12:15:33 +11:00
Matt Joiner 898db894e0 When queuing a piece for hashing after receiving a chunk, clear all the dirty chunks
This should fix a bug triggered by storage inconsistencies.
2017-12-28 23:59:30 +11:00
Matt Joiner fa7c2e2bc6 Code comments 2017-12-03 00:35:09 +11:00
Matt Joiner 4190856b6c sortimports 2017-12-01 18:12:29 +11:00
Matt Joiner 1b9606ae75 The "m" field in the extended handshake is not mandatory 2017-11-08 19:29:55 +11:00
Matt Joiner 9757f04cf8 Apply megacheck to torrent package 2017-11-07 16:11:59 +11:00
Matt Joiner 62b1e1b749 Unbiased request ordering was requesting chunks the peer doesn't have 2017-11-06 14:53:00 +11:00
Matt Joiner be33fc4476 Kick connections requesting pieces we don't have
This was removed at some point, and made the requests received for missing pieces expvar unused.
2017-11-05 15:39:36 +11:00
Matt Joiner 361c8654c7 Add some TODOs 2017-11-05 15:39:35 +11:00
Matt Joiner f12058fc74 Add missing whitespace 2017-11-04 17:08:02 +11:00
Matt Joiner 426c6fec65 Improve upload rate limit burst size panic message
Should help with #202.
2017-11-04 16:58:38 +11:00
Matt Joiner 7e857c875e If closing a connection Conn fails we can't do anything, and there's nothing to say 2017-10-12 17:51:47 +11:00
Matt Joiner 6aad8041ab Implement new request strategy
The new strategy, 2, has the fastest connection download by priority in order, and all other pieces stick to a randomized ordering that's stable per connection.
2017-09-23 15:25:47 +10:00
Matt Joiner 326f60b319 Reduce system call overhead reading from connections 2017-09-21 19:29:56 +10:00
Matt Joiner 67e96686d2 Also post cancels
Should mean that we don't have to wait for the peer requests low water mark before we process chunks to cancel.
2017-09-18 13:47:49 +10:00
Matt Joiner 3ed8274384 Abstract out making a cancel message 2017-09-18 13:42:42 +10:00
Matt Joiner 0790516440 Only run connection.Close once
Avoids unnecessary error messages for net.Conn.Close
2017-09-18 13:40:36 +10:00
Matt Joiner c85aac6383 Log errors closing connection net.Conn's 2017-09-18 12:16:59 +10:00
Matt Joiner bb53c97d38 Move uploading to the connection writer 2017-09-18 12:09:08 +10:00
Matt Joiner 881f1a7e35 Support plaintext crypto method for protocol header encryption 2017-09-13 18:20:20 +10:00
Matt Joiner 4e8f6b8e5b Optimize nextRequestState to return cancel and new requests, and reinstate requestsLowWater 2017-09-02 10:36:43 +10:00
Matt Joiner bad6f07f5e Wrap writerCond in tickleWriter and be more selective about using it 2017-09-01 15:26:50 +10:00
Matt Joiner 110764480e Avoid triggering writer cond where possible 2017-09-01 12:09:41 +10:00
Matt Joiner 361cdc0e08 Track buffered but not posted messages, and unify the expvar names for those counters 2017-09-01 10:53:59 +10:00
Matt Joiner e3479b0bb3 Remove unused code 2017-09-01 10:46:26 +10:00
Matt Joiner d934ec7e30 Add some variables to track fillBuffer effectiveness 2017-09-01 10:36:43 +10:00
Matt Joiner 13e79039f2 Generate requests, cancels and interest state in the connection writer 2017-08-31 23:48:52 +10:00
Matt Joiner 986b9093a0 Make connection.writer pull from a buffer 2017-08-31 16:26:45 +10:00
Matt Joiner c4f5a49c97 Panics while decoding messages in connection.mainLoopRead would trigger more panics 2017-08-31 16:25:49 +10:00
Matt Joiner a8a1ea755d Remove unused functions 2017-08-26 13:23:04 +10:00
Matt Joiner b2d2c524c6 Fix sync.Mutex copy by value
Found by go vet, per https://github.com/anacrolix/torrent/issues/179.
2017-08-25 16:36:34 +10:00
Matt Joiner 76c60ffa77 Try a state-delta function for updating request state
Also adds Torrent.networkingEnabled, though it isn't yet useful.
2017-08-18 01:51:02 +10:00
Matt Joiner 493916c279 Rename Torrent.connHasWantedPieces->connection.peerHasWantedPieces 2017-08-18 01:48:19 +10:00
Matt Joiner 4adee001f7 No longer wanting a piece wasn't triggering an update of connection request state
Pretty minor, but it would leave connections hanging in the interested state.
2017-08-18 01:44:20 +10:00
Matt Joiner 2624281842 Changes for dht-cleanup 2017-07-21 00:40:49 +10:00
Matt Joiner 79d800fe92 Trivial logging, comment, Stringer changes 2017-02-02 16:53:19 +11:00
Matt Joiner a11df82349 package itertools API changed 2017-01-14 20:39:48 +11:00
Matt Joiner 5fe36bbb35 Show connection piece request order in text status 2017-01-04 18:09:50 +11:00
Matt Joiner 174cc0e183 Reduce the priority given to earlier pieces. Maximum priority reads at the end of the file aren’t getting enough attention. 2017-01-04 18:08:29 +11:00
Matt Joiner 9cf09dba8a Remove unused funcs and idents 2017-01-01 11:03:02 +11:00
Matt Joiner 186b5073d2 Move method queuePieceCheck 2017-01-01 11:02:37 +11:00
Matt Joiner 97f6cb496e Avoid deadlock caused by receiving PORT and and DHT announce_peer at the same time 2016-11-28 00:03:10 +11:00
Matt Joiner 4a7fbf6170 Add peers received from received announce_peer DHT messages to the Client
Addresses #133
2016-11-27 00:05:19 +11:00
Matt Joiner fdf75d59c8 Kick only the worst connection when a piece fails a check 2016-11-23 12:59:23 +11:00
Matt Joiner 57b679ffb0 Add a note about dropping connections that we sent a HAVE for incomplete pieces 2016-11-23 11:52:41 +11:00
Matt Joiner 4807c9e29a Make Torrent.conns a map
Can't remember if I've tried this before. But dropping arbitrary connections while iterating established conns will become much simpler.
2016-11-23 11:48:44 +11:00
Matt Joiner ebbd555e7b Move a bunch of Client methods onto more appropriate types 2016-11-22 21:12:53 +11:00
Matt Joiner 90ca45dd2d Don't accept pieces with bad indexes
Fixes #132
2016-11-22 14:20:48 +11:00
Matt Joiner 84d243afca Rename connection.downloadedChunk -> receiveChunk 2016-11-22 14:18:09 +11:00
Matt Joiner 6f9bcff8b2 Make downloadedChunk a method of connection 2016-11-22 14:17:30 +11:00
Matt Joiner 0d9348c5d1 Move Client.downloadedChunk to connection.go 2016-11-22 14:16:18 +11:00
Matt Joiner a49e133d8a Comment on connection.updatePiecePriority
There's also Torrent.updatePiecePriority, and it's always confusing what the difference is.
2016-10-31 16:22:07 +11:00
Matt Joiner 1725133111 Move the implementation of connection.requestPiecePendingChunks out of Torrent 2016-10-25 14:58:17 +11:00
Matt Joiner ed0dbba384 Make newConnection a method on Client 2016-10-10 16:55:56 +11:00
Matt Joiner c34234bf34 Split connection.rw into separate Reader and Writer
This will make it easier to write hooks for Read and Write separately.
2016-10-10 16:30:51 +11:00
Matt Joiner de761fb506 Do chunk pooling at Torrent instead of connection level 2016-10-05 15:57:00 +11:00
Ye Yin d3963eedfd Use sync.pool for decode buffer 2016-09-12 17:32:04 +10:00
Matt Joiner 2fc814b5eb Move Client.connectionLoop to connection.mainReadLoop 2016-09-11 14:32:56 +10:00
Matt Joiner e6d7b52638 Speed up connection.lastHelpful
Moving to reflection and interfaces has made it a bottleneck.
2016-08-14 22:39:23 +10:00
Matt Joiner fbe0ded844 Add connection read stats 2016-07-12 16:42:04 +10:00
Matt Joiner a4e140b939 New slices package 2016-07-12 16:40:14 +10:00
Matt Joiner 240abaf512 Add Torrent.SetMaxEstablishedConns 2016-07-06 00:42:16 +10:00