good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
f5c7d1c8
Commit
f5c7d1c8
authored
Sep 19, 2018
by
Balint Gabor
Committed by
Anton Evangelatov
Sep 19, 2018
Browse files
Options
Downloads
Patches
Plain Diff
swarm/storage: Implement global timeout for fetcher (#17702)
parent
736b45a8
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
swarm/storage/netstore.go
+3
-1
3 additions, 1 deletion
swarm/storage/netstore.go
with
3 additions
and
1 deletion
swarm/storage/netstore.go
+
3
−
1
View file @
f5c7d1c8
...
@@ -52,6 +52,8 @@ type NetStore struct {
...
@@ -52,6 +52,8 @@ type NetStore struct {
closeC
chan
struct
{}
closeC
chan
struct
{}
}
}
var
fetcherTimeout
=
2
*
time
.
Minute
// timeout to cancel the fetcher even if requests are coming in
// NewNetStore creates a new NetStore object using the given local store. newFetchFunc is a
// NewNetStore creates a new NetStore object using the given local store. newFetchFunc is a
// constructor function that can create a fetch function for a specific chunk address.
// constructor function that can create a fetch function for a specific chunk address.
func
NewNetStore
(
store
SyncChunkStore
,
nnf
NewNetFetcherFunc
)
(
*
NetStore
,
error
)
{
func
NewNetStore
(
store
SyncChunkStore
,
nnf
NewNetFetcherFunc
)
(
*
NetStore
,
error
)
{
...
@@ -168,7 +170,7 @@ func (n *NetStore) getOrCreateFetcher(ref Address) *fetcher {
...
@@ -168,7 +170,7 @@ func (n *NetStore) getOrCreateFetcher(ref Address) *fetcher {
// no fetcher for the given address, we have to create a new one
// no fetcher for the given address, we have to create a new one
key
:=
hex
.
EncodeToString
(
ref
)
key
:=
hex
.
EncodeToString
(
ref
)
// create the context during which fetching is kept alive
// create the context during which fetching is kept alive
ctx
,
cancel
:=
context
.
With
Cancel
(
context
.
Background
())
ctx
,
cancel
:=
context
.
With
Timeout
(
context
.
Background
()
,
fetcherTimeout
)
// destroy is called when all requests finish
// destroy is called when all requests finish
destroy
:=
func
()
{
destroy
:=
func
()
{
// remove fetcher from fetchers
// remove fetcher from fetchers
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment