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
Matt Joiner
326b36545b
Prepare to allow max conns per torrent to be configured
2016-07-05 16:23:17 +10:00
Matt Joiner
12191dbfa3
Add counters for uploads
...
Fixes #71 .
2016-07-05 15:52:33 +10:00
Matt Joiner
874bba43f8
Fix crash causing deadlock in connection writer when no messages have been posted yet
2016-06-27 15:45:15 +10:00
Matt Joiner
6cac882030
Reduce the impact of preferring earlier pieces
...
I think urgent pieces at the end of a torrent were getting fairly starved.
2016-05-28 22:04:33 +10:00
Matt Joiner
b55e67dc22
Ban IPs that contribute to failed piece checks
2016-05-24 02:09:47 +10:00
Matt Joiner
d2951c6c4b
Move requestPendingMetadata onto connection from Client
2016-05-16 18:46:38 +10:00
Matt Joiner
dcfee93f96
Fix race marshalling a bitfield after a Have has also been posted
2016-05-11 23:50:21 +10:00
Matt Joiner
69643860ea
Move some behaviour into Client.newConnection
2016-05-07 18:57:38 +10:00
Matt Joiner
0fd73396fd
missinggo.Event changed, connection.writeOptimizer changes
2016-05-07 18:56:44 +10:00
Matt Joiner
63c5ca1f01
Fix crash when peers have sent undersized bitfields and we get the torrent info
2016-04-30 04:08:02 +10:00
Seth Hoenig
9f4bf70e17
refactor struct identifiers to follow conventional go names
2016-04-18 23:11:11 -05:00
Matt Joiner
d3a1c79c79
Merge Torrent and torrent types
2016-04-03 18:40:43 +10:00
Matt Joiner
bfd0b86441
Tidy up the peer have{,all,none},bitfield handling
2016-03-22 12:07:03 +11:00
Matt Joiner
99fa0c26aa
Make peerGotPiece a method on connection
2016-03-21 14:19:51 +11:00
Matt Joiner
1508e02935
Move peerGotPiece
2016-03-21 14:17:15 +11:00
Matt Joiner
409d3695a6
Favour earlier pieces slightly, helps with in-order downloads
2016-03-19 17:40:18 +11:00
Matt Joiner
a6759b321a
Only assert we should be requesting a piece in debug mode
2016-02-15 17:47:04 +11:00
Matt Joiner
5b5ecb8f3b
Still update a connections piece priority even if the peer doesn't have the piece
2016-02-10 00:47:53 +11:00
Matt Joiner
26fa2c4af8
Track posted message type counts
2016-02-10 00:45:47 +11:00
Matt Joiner
3df7d61836
Reintroduce 64 outbound request cap
2016-02-08 16:09:12 +11:00
Matt Joiner
77d6e9e5cb
Use new missinggo iterator style, and speed up torrent.connHasWantedPieces()
2016-02-07 01:22:31 +11:00
Matt Joiner
19a304b8ea
connection.Close must be called under the Client lock
2016-02-02 00:45:26 +11:00
Matt Joiner
afa264e6c5
Reintroduce connection piece inclinations, and begin caching piece priorities
2016-02-01 21:11:41 +11:00
Matt Joiner
3ed628356b
Use missinggo.Event for connection closing event
2016-02-01 21:08:52 +11:00
Matt Joiner
b90dacd324
Abstract the pendingPieces as a bitmap
2016-02-01 01:46:28 +11:00
Matt Joiner
ae9bba2611
Fix downloading of unwanted chunks, and write out downloaded chunks using the connection loop goroutine
...
Doing the writes with the connection loop goroutine prevents memory use blowing out when chunks aren't written out quickly enough.
2016-01-28 05:54:48 +11:00
Matt Joiner
0ad4dda9fc
Move fillRequests and replenishConnRequests into connection.go
2016-01-24 15:21:17 +11:00
Matt Joiner
06445f2a1e
It's working and the tests are usually passing
...
I still need to handle "prefetch"-style downloading, and some functions haven't been committed to force this issue.
2016-01-18 18:35:14 +11:00
Matt Joiner
09050ff2c5
Some missing hunks that fix build
2016-01-04 22:56:36 +11:00
Matt Joiner
3c446086af
Add Have and Bitfield connection methods
2016-01-04 22:37:49 +11:00
Matt Joiner
58c997210e
Track peer sources with a dict, and don't exceed high water mark
2015-09-28 15:30:13 +10:00
Matt Joiner
53259397fc
Initialize connection piece priorities lazily, and using a pool
2015-09-26 17:27:35 +10:00
Matt Joiner
54339a30e3
Drop connections that contributed to pieces that failed to hash
...
There are peers out there that seem to intentionally spam bad data, and the same pieces will often fail continuously. This really puts a bee in their bonnet.
2015-08-04 01:12:09 +10:00
Matt Joiner
1cc50f85a6
connection.writer wasn't working efficiently
...
Because of the pseudo-random selection of a communication in a select statement, flushing was occuring prematurely. Also the buffer was needlessly large. For large messages, like outgoing pieces, it's probably better they just go straight to the wire anyway.
This change will make it easier to implement sending of pieces that doesn't block control messages in the future. Any time that the buffer is empty, we'll be able to signal that it's an optimal time to send a piece.
2015-08-02 20:39:31 +10:00
Matt Joiner
7ecc8108bf
Track connection writes and flushes
...
Helps determine efficiency of the routine.
2015-08-02 14:30:33 +10:00
Matt Joiner
06dede5690
Track the connection flags for completed handshakes
2015-08-02 04:06:22 +10:00
Matt Joiner
58dd6ddf93
Implement Stringer on connection
2015-06-29 19:37:52 +10:00
Matt Joiner
859129fb28
Print peer IDs as escaped ascii
2015-06-22 19:46:26 +10:00
Matt Joiner
ced5733c88
Improve uploading/seeding
2015-06-16 16:57:47 +10:00
Matt Joiner
a2df9f8b01
Miscellaneous changes
2015-06-03 00:03:43 +10:00
Matt Joiner
21fb4933fc
Change the way piece state is exposed to give more detail
2015-06-01 18:22:12 +10:00
Matt Joiner
bc4aa06c91
Comments
2015-06-01 18:17:14 +10:00
Matt Joiner
0d13293d71
Support seeding
2015-05-15 08:39:53 +10:00
Matt Joiner
c5208569ca
Apply sortimports
2015-04-30 00:31:34 +10:00
Matt Joiner
526d9d738e
Rewrite imports to local bencode and metainfo
2015-04-27 14:55:01 +10:00
Matt Joiner
28b299e7c8
Rework the Torrent Reader interface, to allow reader options, and add "responsive" as one such option
...
Had several weeks of testing. Removes a lot of the "helper" reading methods, but this was necessary to allow per-Torrent reading options.
2015-04-14 23:59:41 +10:00
Matt Joiner
60d8ea75a2
Prevent bad metadata_size in extended handshakes from stalling completion of metadata
...
Occasionally bad peers send ridiculous or incorrect metadata_size in their handshakes. If the first acceptable size is wrong, and too small, we'll keep failing metadata completion. If it's too large, honest peers will never send us the pieces we're asking for and we'll never complete the metadata. Now we just adjust the expected metadata size, and keep retrying until we finish. Additionally, we can now request metadata after sending initial messages.
2015-03-27 15:36:59 +11:00
Matt Joiner
3aa78763aa
Use rogpeppe's sortimports to fix this goimports ordering madness
2015-03-26 17:18:08 +11:00
Matt Joiner
842a32ae0c
Rewrite import paths for migration from Bitbucket
2015-03-20 16:37:44 +11:00
Matt Joiner
30c67caced
Allow some overlap between piece prioritization classes
...
This probabilistically improves download speeds when doing readaheads
2015-03-20 10:52:55 +11:00
Matt Joiner
466b5f0623
Improve connection status info, especially flags
2015-03-18 18:38:29 +11:00
Matt Joiner
a7dddd9be6
Rewrite handshaking and connection management
2015-03-18 18:28:13 +11:00
Matt Joiner
203da0aab0
Tidy up extension bytes handling; don't close conn from handshake writer; force protocol encryption for now
2015-03-13 06:21:13 +11:00
Matt Joiner
e85b7e228b
Add support for Fast Extension
2015-03-12 20:06:23 +11:00
Matt Joiner
92e0679b04
Change piece prioritization
2015-02-21 15:02:31 +11:00
Matt Joiner
ae7261c392
Break active peer status line up
2015-02-10 00:19:56 +11:00
Matt Joiner
2c48152b10
Code comments
2015-01-22 00:42:03 +11:00
Matt Joiner
8e7e551d76
Fix comment
2015-01-11 00:17:25 +11:00
Matt Joiner
bcebf569b8
Favour earlier pieces
2015-01-11 00:17:18 +11:00