]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Misc trivial improvements
authorMatt Joiner <anacrolix@gmail.com>
Mon, 25 Aug 2014 12:14:10 +0000 (22:14 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 25 Aug 2014 12:14:10 +0000 (22:14 +1000)
client.go
cmd/torrent/main.go
dht/dht.go
download_strategies.go
fs/torrentfs.go
torrent.go

index b02d9a50f486fb126a98d192e5afa4f146dadacb..a519e0c3cda4cb6b063f7adc9c56046cf6f19a6f 100644 (file)
--- a/client.go
+++ b/client.go
@@ -1271,7 +1271,7 @@ func (me *Client) downloadedChunk(t *torrent, c *connection, msg *pp.Message) er
        // Write the chunk out.
        err := t.WriteChunk(int(msg.Index), int64(msg.Begin), msg.Piece)
        if err != nil {
-               return err
+               return fmt.Errorf("error writing chunk: %s", err)
        }
 
        // Record that we have the chunk.
index 294923360d9a3749b02ce0cfac326225bdeb81c1..142b1d339d5e7b6b30b8a23a288374c02dfce0dc 100644 (file)
@@ -26,12 +26,9 @@ var (
        seed            = flag.Bool("seed", false, "seed after downloading")
 )
 
-func init() {
+func main() {
        log.SetFlags(log.LstdFlags | log.Lshortfile)
        flag.Parse()
-}
-
-func main() {
        if *httpAddr != "" {
                util.LoggedHTTPServe(*httpAddr)
        }
index b77324b05af87d8193c815be60c9d0e321b4b740..bf3b3f5a7c45699cacf733a85a6da6242c0af5e7 100644 (file)
@@ -141,7 +141,11 @@ func (t *transaction) handleResponse(m Msg) {
        if t.onResponse != nil {
                t.onResponse(m)
        }
-       t.Response <- m
+       select {
+       case t.Response <- m:
+       default:
+               panic("blocked handling response")
+       }
        close(t.Response)
 }
 
index 1de19a5b5682fbe43a13c11b5b60126ee5717a10..6b2886118d504d73e7d1393b0c1ec9da790972ed 100644 (file)
@@ -8,12 +8,12 @@ import (
 )
 
 type DownloadStrategy interface {
-       FillRequests(t *torrent, c *connection)
-       TorrentStarted(*torrent)
-       TorrentStopped(*torrent)
-       DeleteRequest(t *torrent, r request)
+       FillRequests(*torrent, *connection)
+       TorrentStarted(*torrent)
+       TorrentStopped(*torrent)
+       DeleteRequest(*torrent, request)
        TorrentPrioritize(t *torrent, off, _len int64)
-       TorrentGotChunk(t *torrent, r request)
+       TorrentGotChunk(*torrent, request)
        TorrentGotPiece(t *torrent, piece int)
        WriteStatus(w io.Writer)
        AssertNotRequested(*torrent, request)
@@ -130,7 +130,7 @@ func (me *responsiveDownloadStrategy) WriteStatus(w io.Writer) {
        for t, pp := range me.priorities {
                fmt.Fprintf(w, "\t%s:", t.Name())
                for r := range pp {
-                       fmt.Fprintf(w, "%v ", r)
+                       fmt.Fprintf(w, " %v", r)
                }
                fmt.Fprintln(w)
        }
index e0816befdecbba84f0b2efa397b86bb43b1fdbcf..31891effbf021cd7ba678aa50061a53b0e404f8d 100644 (file)
@@ -55,7 +55,7 @@ func (n *node) fsPath() string {
 
 func (fn fileNode) Read(req *fuse.ReadRequest, resp *fuse.ReadResponse, intr fusefs.Intr) fuse.Error {
        if req.Dir {
-               panic("hodor")
+               panic("read on directory")
        }
        log.Printf("read request for %s: offset=%d size=%d", fn.fsPath(), req.Offset, req.Size)
        size := req.Size
index 82256f1e4284dbaa8c197de3bb38cdc5db343ff2..4c2a476ebe1ec7f7452653f50a17b4d6ac813fe7 100644 (file)
@@ -258,12 +258,6 @@ func (t *torrent) WriteStatus(w io.Writer) {
                fmt.Fprintf(w, "%c", t.pieceStatusChar(index))
        }
        fmt.Fprintln(w)
-       // fmt.Fprintln(w, "Priorities: ")
-       // if t.Priorities != nil {
-       //      for e := t.Priorities.Front(); e != nil; e = e.Next() {
-       //              fmt.Fprintf(w, "\t%v\n", e.Value)
-       //      }
-       // }
        fmt.Fprintf(w, "Pending peers: %d\n", len(t.Peers))
        fmt.Fprintf(w, "Active peers: %d\n", len(t.Conns))
        for _, c := range t.Conns {