Commit c9aa3744 authored by Bob Potter's avatar Bob Potter

Revert "buffer writes"

This reverts commit fc1278e6.

It appears that using a buffer here is no longer necessary after the
upstream fix https://github.com/gogo/protobuf/pull/504
parent 98550f76
package network package network
import ( import (
"bufio"
"context" "context"
"fmt" "fmt"
"io" "io"
...@@ -74,20 +73,19 @@ func msgToStream(ctx context.Context, s inet.Stream, msg bsmsg.BitSwapMessage) e ...@@ -74,20 +73,19 @@ func msgToStream(ctx context.Context, s inet.Stream, msg bsmsg.BitSwapMessage) e
if dl, ok := ctx.Deadline(); ok { if dl, ok := ctx.Deadline(); ok {
deadline = dl deadline = dl
} }
if err := s.SetWriteDeadline(deadline); err != nil { if err := s.SetWriteDeadline(deadline); err != nil {
log.Warningf("error setting deadline: %s", err) log.Warningf("error setting deadline: %s", err)
} }
w := bufio.NewWriter(s)
switch s.Protocol() { switch s.Protocol() {
case ProtocolBitswap: case ProtocolBitswap:
if err := msg.ToNetV1(w); err != nil { if err := msg.ToNetV1(s); err != nil {
log.Debugf("error: %s", err) log.Debugf("error: %s", err)
return err return err
} }
case ProtocolBitswapOne, ProtocolBitswapNoVers: case ProtocolBitswapOne, ProtocolBitswapNoVers:
if err := msg.ToNetV0(w); err != nil { if err := msg.ToNetV0(s); err != nil {
log.Debugf("error: %s", err) log.Debugf("error: %s", err)
return err return err
} }
...@@ -95,11 +93,6 @@ func msgToStream(ctx context.Context, s inet.Stream, msg bsmsg.BitSwapMessage) e ...@@ -95,11 +93,6 @@ func msgToStream(ctx context.Context, s inet.Stream, msg bsmsg.BitSwapMessage) e
return fmt.Errorf("unrecognized protocol on remote: %s", s.Protocol()) 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 { if err := s.SetWriteDeadline(time.Time{}); err != nil {
log.Warningf("error resetting deadline: %s", err) log.Warningf("error resetting deadline: %s", err)
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment