Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-bitswap
Commits
5251947b
Unverified
Commit
5251947b
authored
Oct 18, 2018
by
Steven Allen
Committed by
GitHub
Oct 18, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #15 from ipfs/fix/buffer-write
buffer writes
parents
e12de92f
fc1278e6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
3 deletions
+10
-3
network/ipfs_impl.go
network/ipfs_impl.go
+10
-3
No files found.
network/ipfs_impl.go
View file @
5251947b
package
network
import
(
"bufio"
"context"
"fmt"
"io"
...
...
@@ -70,19 +71,20 @@ 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
(
s
);
err
!=
nil
{
if
err
:=
msg
.
ToNetV1
(
w
);
err
!=
nil
{
log
.
Debugf
(
"error: %s"
,
err
)
return
err
}
case
ProtocolBitswapOne
,
ProtocolBitswapNoVers
:
if
err
:=
msg
.
ToNetV0
(
s
);
err
!=
nil
{
if
err
:=
msg
.
ToNetV0
(
w
);
err
!=
nil
{
log
.
Debugf
(
"error: %s"
,
err
)
return
err
}
...
...
@@ -90,6 +92,11 @@ func msgToStream(ctx context.Context, s inet.Stream, msg bsmsg.BitSwapMessage) e
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
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment