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
189564ed
Commit
189564ed
authored
Apr 16, 2020
by
Dirk McCormick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: shutdown message queue when there's a send error
parent
ba4b52e7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
0 deletions
+11
-0
internal/messagequeue/messagequeue.go
internal/messagequeue/messagequeue.go
+4
-0
network/ipfs_impl.go
network/ipfs_impl.go
+7
-0
No files found.
internal/messagequeue/messagequeue.go
View file @
189564ed
...
...
@@ -359,6 +359,8 @@ func (mq *MessageQueue) runQueue() {
return
case
<-
mq
.
ctx
.
Done
()
:
if
mq
.
sender
!=
nil
{
// TODO: should I call sender.Close() here also to stop
// and in progress connection?
_
=
mq
.
sender
.
Reset
()
}
return
...
...
@@ -415,6 +417,7 @@ func (mq *MessageQueue) sendMessage() {
// If we fail to initialize the sender, the networking layer will
// emit a Disconnect event and the MessageQueue will get cleaned up
log
.
Infof
(
"Could not open message sender to peer %s: %s"
,
mq
.
p
,
err
)
mq
.
Shutdown
()
return
}
...
...
@@ -439,6 +442,7 @@ func (mq *MessageQueue) sendMessage() {
// If the message couldn't be sent, the networking layer will
// emit a Disconnect event and the MessageQueue will get cleaned up
log
.
Infof
(
"Could not send message to peer %s: %s"
,
mq
.
p
,
err
)
mq
.
Shutdown
()
return
}
...
...
network/ipfs_impl.go
View file @
189564ed
...
...
@@ -112,6 +112,13 @@ func (s *streamMessageSender) Connect(ctx context.Context) (stream network.Strea
return
nil
,
err
}
// Check if the sender has been closed
select
{
case
<-
s
.
done
:
return
nil
,
nil
default
:
}
stream
,
err
=
s
.
bsnet
.
newStreamToPeer
(
ctx
,
s
.
to
)
if
err
==
nil
{
s
.
stream
=
stream
...
...
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