Comments (7)
Yes, i'm experience a hang larger than TrackerStopTimeout
.
It's not the stopping torrent's PerioidAnnouncer that hangs, it's other running torrents's PerioidAnnouncer hang because of udp tracker.
All announcers share the same udptracker.Transport
in TrackerManager
type TrackerManager struct {
httpTransport *http.Transport
udpTransport *udptracker.Transport
}
And there is one lock in udptracker.Transport
func (t *Transport) getConnection(addr string) *connection {
t.m.Lock()
defer t.m.Unlock()
conn, ok := t.connections[addr]
if !ok {
conn = new(connection)
t.connections[addr] = conn
}
return conn
}
So when we get lock and hang in Transport.retryTransaction
, then another torrent call Transport.getConnection
will hang too.
func (t *Transport) retryTransaction(ctx context.Context, f func(*transaction), trx *transaction) ([]byte, error) {
// this hang until udp tracker done
// before that, all other torrents call getConnection will hang because of this lock
t.m.Lock()
t.transactions[trx.ID()] = trx
t.m.Unlock()
...
}
And yes, the stopping torrent's announcer.NewStopAnnouncer
will hang for a long time, that's what i'm experiencing
Maybe i'm wrong, but please check anyway, thanks.
from rain.
I think I get this. I have a solution in my mind. I'll try to implement this weekend.
from rain.
When stopping a torrent, in order to prevent this scenario, first, PerioidAnnouncer
s are stopped. This operation does not block.
Line 67 in fc79f0f
The torrent goes into Stopping state.
Then, another Announcer
is started that will only announce one time, with a timeout of TrackerStopTimeout
which is 5 seconds by default (but configurable via config file). This is required to tell the tracker that we are stopping the torrent and tell it to remove our client from the peer list.
Line 93 in fc79f0f
This still does not hang. If you don't want to wait for last announce, you can call Torrent.Stop()
again to stop it immediately.
Do you experience a hang larger than TrackerStopTimeout
?
from rain.
I think I get this. I have a solution in my mind. I'll try to implement this weekend.
Hi @cenkalti οΌis there any progress?
from rain.
Sorry, I didn't have enough time. I'll try to look again this weekend.
from rain.
Hey @kylege . This issue turned out to be a larger refactor rather that a small fix. I removed the lock completely and replaced it with a goroutine in UDP transport. I already merged it after testing on my own seedbox but feel free to comment and ask questions on the commit: 3321278
Please let me know what do you think. Cheers!
from rain.
Hey @kylege . This issue turned out to be a larger refactor rather that a small fix. I removed the lock completely and replaced it with a goroutine in UDP transport. I already merged it after testing on my own seedbox but feel free to comment and ask questions on the commit: 3321278
Please let me know what do you think. Cheers!
Nice work! Problem solved perfectly.
from rain.
Related Issues (20)
- Logger in library mode HOT 3
- data race between torrent.(*Session).insertTorrent() and torrent.(*Session).processDHTResults() HOT 2
- panic: already have the piece #987 HOT 3
- Health check crashes while printing a log statement HOT 5
- Panic when tracker announce fail HOT 1
- Speed limit issue HOT 6
- Removed torrent directory after download HOT 1
- torrent_start.go:116 cannot listen port error HOT 14
- Why do you use a sstree instead of a key/value pair? HOT 3
- Status: Stopped: file allocation error HOT 4
- can i see how many total bytes was uploaded or transfered to another peer ? HOT 1
- Support binding to any port (for testing, 127.0.0.1) for acceptor HOT 2
- Feature request: each torrent may have different store location HOT 1
- remove or edit peer and tracker HOT 7
- Does this repo need go 1.18? HOT 1
- Support for BitComet Padding files HOT 1
- Improvement to 'console' HOT 2
- Exposing per-File data? HOT 10
- close of closed channel in peer.(*pex).close(...) HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rain.