Commit Graph

192 Commits

Author SHA1 Message Date
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