t, err := cl.receiveHandshakes(c)
if err != nil {
log.Fmsg(
- "error receiving handshakes: %s", err,
+ "error receiving handshakes on %v: %s", c, err,
).AddValue(
debugLogValue,
).Add(
}
}
}
- }
- if len(cn.requests) <= cn.requestsLowWater {
+ } else if len(cn.requests) <= cn.requestsLowWater {
filledBuffer := false
cn.iterPendingPieces(func(pieceIndex pieceIndex) bool {
cn.iterPendingRequests(pieceIndex, func(r request) bool {
defer cl.lock()
concurrentChunkWrites.Add(1)
defer concurrentChunkWrites.Add(-1)
- // Write the chunk out. Note that the upper bound on chunk writing
- // concurrency will be the number of connections. We write inline with
- // receiving the chunk (with this lock dance), because we want to
- // handle errors synchronously and I haven't thought of a nice way to
- // defer any concurrency to the storage and have that notify the
- // client of errors. TODO: Do that instead.
+ // Write the chunk out. Note that the upper bound on chunk writing concurrency will be the
+ // number of connections. We write inline with receiving the chunk (with this lock dance),
+ // because we want to handle errors synchronously and I haven't thought of a nice way to
+ // defer any concurrency to the storage and have that notify the client of errors. TODO: Do
+ // that instead.
return t.writeChunk(int(msg.Index), int64(msg.Begin), msg.Piece)
}()
assert.EqualValues(t, 0, pos)
_greeting, err := ioutil.ReadAll(r)
assert.NoError(t, err)
- assert.EqualValues(t, testutil.GreetingFileContents, _greeting)
+ assert.EqualValues(t, testutil.GreetingFileContents, string(_greeting))
}
// Creates a seeder and a leecher, and ensures the data transfers when a read