-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cleanup ctxgroup goprocess #1385
Conversation
0c080cd
to
ef921b4
Compare
@@ -104,7 +105,7 @@ type IpfsNode struct { | |||
|
|||
IpnsFs *ipnsfs.Filesystem | |||
|
|||
ctxgroup.ContextGroup | |||
goprocess.Process |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what i've been doing with goprocess is to make this a variable, not embedded type:
type Object struct {
proc goprocess.Process
}
And then have a function that returns the process.
func (o Object) Process() goprocess.Process {
return o.proc
}
the reason is that the Process interface is pretty large and embedding it dumps a bunch of objects on the user. maybe move to that? sorry for not describing it earlier.
I'll wait till the |
How to |
Still want to know how it was done. |
ef921b4
to
dfa843c
Compare
@rht this is a typical flow. # first, make sure my github.com/jbenet/goprocess dir is up to date
go get -u github.com/jbenet/goprocess
# or if that fails (dirty working dir or something):
cd ~/go/src/github.com/jbenet/goprocess && git fetch
# tell godep to update github.com/jbenet/goprocess
cd ~/go/src/github.com/ipfs/go-ipfs
godep update github.com/jbenet/goprocess
# if godep errors with "cannot build package X" it usually means i don't
# have the version needed locally. One can try using `godep restore`
# but i like minimizing what godep touches, so i usually just update them manually:
go get -u github.com/jbenet/go-random
go get -u github.com/chriscool/go-sleep
...
# godep update should work now.
godep update github.com/jbenet/goprocess
# after updating, run `make vendor` to rewrite paths, if any have changed.
make vendor
# this _may_ remove godeps accidentally that shouldnt be removed. just dont
# commit those deletions, and just `git checkout Godeps/_workspace/...` them back
# selectively add only the bits we want:
# the vendored dir, and the updated line for the repo in the Godeps.json
git add -p Godeps/ |
Thanks for writing that. It is ... very detailed and thorough. i c so it is
If there is out-of-box way to To sum up my surprise: why isn't update: works now. |
d63cc0d
to
7dffde7
Compare
@jbenet rebased and added Process() method, except for IpfsNode where it requires the process to be assigned externally. |
what's the requirement? if lots of things call Close, so we can write a simple method like: func (node *IpfsNode) Close() error {
return node.proc.Close()
} or something |
19d1744
to
6d27119
Compare
@jbenet fixed. |
? @rht i still think this is unsafe. it's a race that was there earlier. Maybe this can fix it: proc := goprocess.WithTeardown(node.teardown)
goprocessctx.WaitForContext(ctx, proc) or maybe can make a function in https://github.com/jbenet/goprocess/blob/master/context/context.go like: func WithContextAndTeardown(ctx context.Context, tf goprocess.TeardownFunc) goprocess.Process {
if ctx == nil {
panic("nil Context")
}
p := goprocess.WithTeardown(tf)
go func() {
<-ctx.Done()
p.Close()
}()
return p
} |
Then is it likely that any code using |
For processes that spawn from a context or parent processes yes. (Which I guess is most cases where SetTeardown would be called). We could actually fix this with a hack that may be semantically ok: if SetTeardown is called after the process is called, immediately call The teardown function. (Calling SetTeardown twice could be defined to be an error). — On Mon, Jun 22, 2015 at 3:23 AM, rht notifications@github.com wrote:
|
Hasn't this been done in https://github.com/jbenet/goprocess/blob/master/impl-mutex.go#L199 already? |
361be7c
to
2f13ac2
Compare
i think that doesn't clear the parent's ptr to the |
@rht +1 to all the |
2f13ac2
to
93ac8fb
Compare
I c, so what needs to be done is when the parent calls |
License: MIT Signed-off-by: rht <rhtbot@gmail.com>
License: MIT Signed-off-by: rht <rhtbot@gmail.com>
License: MIT Signed-off-by: rht <rhtbot@gmail.com>
f7b7226
to
4c74119
Compare
RFM. This will be for a separate PR:
A |
Identity: config.Identity{ | ||
PeerID: p.String(), | ||
}, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this is right, but @whyrusleeping can you check too?
Hey @rht solid progress. almost there! I found another problem: #1385 (comment) that's my fault for not making |
Also, make sure you rebase on latest master (haven't checked if this is rebased or not, just have merged many things recently) |
License: MIT Signed-off-by: rht <rhtbot@gmail.com>
License: MIT Signed-off-by: rht <rhtbot@gmail.com>
License: MIT Signed-off-by: rht <rhtbot@gmail.com>
4c74119
to
3daf749
Compare
Also replaced anything with regex |
this LGTM. merging, thanks @rht ! |
Cleanup ctxgroup goprocess This commit was moved from ipfs/kubo@4c55b30
Close #1030
Pending waiting for goprocess to have
SetTeardown()