Skip to content

Commit

Permalink
Revert "buffer writes"
Browse files Browse the repository at this point in the history
This reverts commit 3ac3a96.

It appears that using a buffer here is no longer necessary after the
upstream fix gogo/protobuf#504


This commit was moved from ipfs/go-bitswap@c9aa374
  • Loading branch information
bpot committed Mar 27, 2019
1 parent 207ae1d commit a2360cd
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions bitswap/network/ipfs_impl.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package network

import (
"bufio"
"context"
"fmt"
"io"
Expand Down Expand Up @@ -74,32 +73,26 @@ func msgToStream(ctx context.Context, s inet.Stream, msg bsmsg.BitSwapMessage) e
if dl, ok := ctx.Deadline(); ok {
deadline = dl
}

if err := s.SetWriteDeadline(deadline); err != nil {
log.Warningf("error setting deadline: %s", err)
}

w := bufio.NewWriter(s)

switch s.Protocol() {
case ProtocolBitswap:
if err := msg.ToNetV1(w); err != nil {
if err := msg.ToNetV1(s); err != nil {
log.Debugf("error: %s", err)
return err
}
case ProtocolBitswapOne, ProtocolBitswapNoVers:
if err := msg.ToNetV0(w); err != nil {
if err := msg.ToNetV0(s); err != nil {
log.Debugf("error: %s", err)
return err
}
default:
return fmt.Errorf("unrecognized protocol on remote: %s", s.Protocol())
}

if err := w.Flush(); err != nil {
log.Debugf("error: %s", err)
return err
}

if err := s.SetWriteDeadline(time.Time{}); err != nil {
log.Warningf("error resetting deadline: %s", err)
}
Expand Down

0 comments on commit a2360cd

Please sign in to comment.