From 74106fc296103ce902da95e46abb12c675361084 Mon Sep 17 00:00:00 2001 From: Mark Holt Date: Sun, 30 Jun 2024 20:09:12 +0100 Subject: [PATCH] mk printer --- peer.go | 2 +- storage/mmap.go | 1 + torrent.go | 6 ++++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/peer.go b/peer.go index 7d58d4f013..ea37ddd23a 100644 --- a/peer.go +++ b/peer.go @@ -571,7 +571,7 @@ func (me *Peer) cancel(r RequestIndex, updateRequests bool, lock bool, lockTorre } if !me.deleteRequest(r, false, false) { - panic("request not existing should have been guarded") + panic(fmt.Sprintf("request %d not existing: should have been guarded", r)) } if me._cancel(r, false, false) { // Record that we expect to get a cancel ack. diff --git a/storage/mmap.go b/storage/mmap.go index d54cd0ad6b..cb61bb56c7 100644 --- a/storage/mmap.go +++ b/storage/mmap.go @@ -119,6 +119,7 @@ func (sp mmapStoragePiece) Completion() Completion { } func (sp mmapStoragePiece) MarkComplete() error { + fmt.Println("MK", sp.ih, sp.p.Index()) sp.pc.Set(sp.pieceKey(), true) return nil } diff --git a/torrent.go b/torrent.go index 044dca4fb3..a510c5586a 100644 --- a/torrent.go +++ b/torrent.go @@ -1212,7 +1212,7 @@ func (t *Torrent) offsetRequest(off int64) (req Request, ok bool) { func (t *Torrent) writeChunk(piece int, begin int64, data []byte, lock bool) (err error) { //defer perf.ScopeTimerErr(&err)() - fmt.Println("WRT", t.infoHash, piece, begin, uint32(begin/int64(len(data)))) + fmt.Println("WRT", t.infoHash, piece) n, err := t.piece(piece, lock).Storage().WriteAt(data, begin) if err == nil && n != len(data) { err = io.ErrShortWrite @@ -2705,7 +2705,7 @@ func (t *Torrent) pieceHashed(piece pieceIndex, passed bool, hashIoErr error) { t.clearPieceTouchers(piece, true) if p.hasDirtyChunks(true) { - p.Flush() // You can be synchronous here! + p.Flush() } err := p.Storage().MarkComplete() @@ -2965,7 +2965,9 @@ func (t *Torrent) processHashResults() { } t.pieceHashed(result.index, result.correct, result.copyErr) + fmt.Println("UPP", result.index) t.updatePiecePriority(result.index, "Torrent.pieceHasher", true) + fmt.Println("UPP", result.index, "DONE") return nil }) }(result)