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-dms3
Commits
afd497e1
Commit
afd497e1
authored
10 years ago
by
Konstantin Koroviev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dirty hack to fix race conditions in the daemon
parent
e0cf24bf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
3 deletions
+19
-3
cmd/ipfs/daemon.go
cmd/ipfs/daemon.go
+4
-0
cmd/ipfs/main.go
cmd/ipfs/main.go
+11
-0
commands/request.go
commands/request.go
+4
-3
No files found.
cmd/ipfs/daemon.go
View file @
afd497e1
...
...
@@ -267,6 +267,10 @@ func daemonFunc(req cmds.Request, res cmds.Response) {
gateway
.
ServeOption
(),
corehttp
.
VersionOption
(),
}
// our global interrupt handler can now try to stop the daemon
close
(
req
.
Context
()
.
ContextIsReadyToBeClosed
)
if
rootRedirect
!=
nil
{
opts
=
append
(
opts
,
rootRedirect
)
}
...
...
This diff is collapsed.
Click to expand it.
cmd/ipfs/main.go
View file @
afd497e1
...
...
@@ -132,6 +132,14 @@ func main() {
os
.
Exit
(
1
)
}
// our global interrupt handler may try to stop the daemon
// before the daemon is ready to be stopped; this dirty
// workaround is for the daemon only; other commands are always
// ready to be stopped
if
invoc
.
cmd
!=
daemonCmd
{
close
(
invoc
.
req
.
Context
()
.
ContextIsReadyToBeClosed
)
}
// ok, finally, run the command invocation.
output
,
err
:=
invoc
.
Run
(
ctx
)
if
err
!=
nil
{
...
...
@@ -473,6 +481,9 @@ func (i *cmdInvocation) setupInterruptHandler() {
sig
:=
allInterruptSignals
()
go
func
()
{
// wait till the context is ready to be closed
<-
ctx
.
ContextIsReadyToBeClosed
// first time, try to shut down.
// loop because we may be
...
...
This diff is collapsed.
Click to expand it.
commands/request.go
View file @
afd497e1
...
...
@@ -28,8 +28,9 @@ type Context struct {
config
*
config
.
Config
LoadConfig
func
(
path
string
)
(
*
config
.
Config
,
error
)
node
*
core
.
IpfsNode
ConstructNode
func
()
(
*
core
.
IpfsNode
,
error
)
node
*
core
.
IpfsNode
ConstructNode
func
()
(
*
core
.
IpfsNode
,
error
)
ContextIsReadyToBeClosed
chan
bool
}
// GetConfig returns the config of the current Command exection
...
...
@@ -287,7 +288,7 @@ func NewRequest(path []string, opts OptMap, args []string, file files.File, cmd
optDefs
=
make
(
map
[
string
]
Option
)
}
ctx
:=
Context
{
Context
:
context
.
TODO
()}
ctx
:=
Context
{
Context
:
context
.
TODO
()
,
ContextIsReadyToBeClosed
:
make
(
chan
bool
)
}
values
:=
make
(
map
[
string
]
interface
{})
req
:=
&
request
{
path
,
opts
,
args
,
file
,
cmd
,
ctx
,
optDefs
,
values
,
os
.
Stdin
}
err
:=
req
.
ConvertOptions
()
...
...
This diff is collapsed.
Click to expand it.
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