Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mybee
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
mybee
Commits
2af9c6a9
Unverified
Commit
2af9c6a9
authored
Jul 08, 2020
by
Petar Radovic
Committed by
GitHub
Jul 08, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pushsync - stream reset (#422)
* pushsync zombie threads
parent
d9c674b0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
4 deletions
+19
-4
pushsync.go
pkg/pushsync/pushsync.go
+19
-4
No files found.
pkg/pushsync/pushsync.go
View file @
2af9c6a9
...
...
@@ -80,9 +80,15 @@ func (s *PushSync) Protocol() p2p.ProtocolSpec {
// handler handles chunk delivery from other node and forwards to its destination node.
// If the current node is the destination, it stores in the local store and sends a receipt.
func
(
ps
*
PushSync
)
handler
(
ctx
context
.
Context
,
p
p2p
.
Peer
,
stream
p2p
.
Stream
)
error
{
func
(
ps
*
PushSync
)
handler
(
ctx
context
.
Context
,
p
p2p
.
Peer
,
stream
p2p
.
Stream
)
(
err
error
)
{
w
,
r
:=
protobuf
.
NewWriterAndReader
(
stream
)
defer
stream
.
Close
()
defer
func
()
{
if
err
!=
nil
{
_
=
stream
.
Reset
()
}
else
{
_
=
stream
.
FullClose
()
}
}()
// Get the delivery
chunk
,
err
:=
ps
.
getChunkDelivery
(
r
)
...
...
@@ -135,7 +141,13 @@ func (ps *PushSync) handler(ctx context.Context, p p2p.Peer, stream p2p.Stream)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"new stream peer %s: %w"
,
peer
.
String
(),
err
)
}
defer
streamer
.
Close
()
defer
func
()
{
if
err
!=
nil
{
_
=
streamer
.
Reset
()
}
else
{
go
streamer
.
FullClose
()
}
}()
wc
,
rc
:=
protobuf
.
NewWriterAndReader
(
streamer
)
if
err
:=
ps
.
sendChunkDelivery
(
wc
,
chunk
);
err
!=
nil
{
...
...
@@ -230,10 +242,11 @@ func (ps *PushSync) PushChunkToClosest(ctx context.Context, ch swarm.Chunk) (*Re
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"new stream for peer %s: %w"
,
peer
.
String
(),
err
)
}
defer
streamer
.
Close
()
defer
func
()
{
go
streamer
.
FullClose
()
}
()
w
,
r
:=
protobuf
.
NewWriterAndReader
(
streamer
)
if
err
:=
ps
.
sendChunkDelivery
(
w
,
ch
);
err
!=
nil
{
_
=
streamer
.
Reset
()
return
nil
,
fmt
.
Errorf
(
"chunk deliver to peer %s: %w"
,
peer
.
String
(),
err
)
}
// if you manage to get a tag, just increment the respective counter
...
...
@@ -245,6 +258,7 @@ func (ps *PushSync) PushChunkToClosest(ctx context.Context, ch swarm.Chunk) (*Re
receiptRTTTimer
:=
time
.
Now
()
receipt
,
err
:=
ps
.
receiveReceipt
(
r
)
if
err
!=
nil
{
_
=
streamer
.
Reset
()
return
nil
,
fmt
.
Errorf
(
"receive receipt from peer %s: %w"
,
peer
.
String
(),
err
)
}
ps
.
metrics
.
ReceiptRTT
.
Observe
(
time
.
Since
(
receiptRTTTimer
)
.
Seconds
())
...
...
@@ -252,6 +266,7 @@ func (ps *PushSync) PushChunkToClosest(ctx context.Context, ch swarm.Chunk) (*Re
// Check if the receipt is valid
if
!
ch
.
Address
()
.
Equal
(
swarm
.
NewAddress
(
receipt
.
Address
))
{
ps
.
metrics
.
InvalidReceiptReceived
.
Inc
()
_
=
streamer
.
Reset
()
return
nil
,
fmt
.
Errorf
(
"invalid receipt. peer %s"
,
peer
.
String
())
}
...
...
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