{"action":"created","comment":{"url":"https://api.github.com/repos/ipfs/go-ipfs/pulls/comments/33890519","id":33890519,"diff_hunk":"@@ -71,15 +73,17 @@ func NewDHT(ctx context.Context, h host.Host, dstore ds.ThreadSafeDatastore) *Ip\n \t// register for network notifs.\n \tdht.host.Network().Notify((*netNotifiee)(dht))\n \n-\tdht.ContextGroup = ctxgroup.WithContextAndTeardown(ctx, func() error {\n+\tdht.proc = goprocessctx.WithContextAndTeardown(ctx, func() error {\n \t\t// remove ourselves from network notifs.\n \t\tdht.host.Network().StopNotify((*netNotifiee)(dht))\n \t\treturn nil\n \t})\n \n+\tdht.ctx = ctx\n+\n \th.SetStreamHandler(ProtocolDHT, dht.handleNewStream)\n-\tdht.providers = NewProviderManager(dht.Context(), dht.self)\n-\tdht.AddChild(dht.providers)\n+\tdht.providers = NewProviderManager(dht.ctx, dht.self)\n+\tdht.proc.AddChild(dht.providers.proc)","path":"routing/dht/dht.go","position":38,"original_position":38,"commit_id":"4c741193a4132c42db81dd0eb52595643f03f3ea","original_commit_id":"4c741193a4132c42db81dd0eb52595643f03f3ea","user":{"login":"jbenet","id":138401,"avatar_url":"https://avatars.githubusercontent.com/u/138401?v=3","gravatar_id":"","url":"https://api.github.com/users/jbenet","html_url":"https://github.com/jbenet","followers_url":"https://api.github.com/users/jbenet/followers","following_url":"https://api.github.com/users/jbenet/following{/other_user}","gists_url":"https://api.github.com/users/jbenet/gists{/gist_id}","starred_url":"https://api.github.com/users/jbenet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbenet/subscriptions","organizations_url":"https://api.github.com/users/jbenet/orgs","repos_url":"https://api.github.com/users/jbenet/repos","events_url":"https://api.github.com/users/jbenet/events{/privacy}","received_events_url":"https://api.github.com/users/jbenet/received_events","type":"User","site_admin":false},"body":"not 100% this is safe.\r\n\r\n```go\r\ndht.proc = goprocessctx.WithContextAndTeardown(...)\r\n// suppose ctx is cancelled here\r\ndht.proc.AddChild(dht.providers.proc) // proc may be closed by here.\r\n```\r\nAnd will this panic. (we need way better semantics on the interaction with contexts)\r\n\r\ni believe we want this:\r\n```go\r\ndht.proc = goprocess.WithTeardown(...) \r\ndht.proc.AddChild(dht.providers.proc)\r\n// ok, now safe to close.\r\ngo func() {\r\n  <-ctx.Done()\r\n  dht.proc.Close()\r\n}()\r\n```\r\n\r\nI just made `CloseAfterContext(p, ctx)` in https://github.com/jbenet/goprocess/pull/8 so just:\r\n\r\n```go\r\ndht.proc = goprocess.WithTeardown(...) \r\ndht.proc.AddChild(dht.providers.proc)\r\n// ok, now safe to close.\r\ngoprocessctx.CloseAfterContext(dht.proc, ctx)\r\n```\r\n","created_at":"2015-07-04T22:52:13Z","updated_at":"2015-07-04T22:52:13Z","html_url":"https://github.com/ipfs/go-ipfs/pull/1385#discussion_r33890519","pull_request_url":"https://api.github.com/repos/ipfs/go-ipfs/pulls/1385","_links":{"self":{"href":"https://api.github.com/repos/ipfs/go-ipfs/pulls/comments/33890519"},"html":{"href":"https://github.com/ipfs/go-ipfs/pull/1385#discussion_r33890519"},"pull_request":{"href":"https://api.github.com/repos/ipfs/go-ipfs/pulls/1385"}}},"pull_request":{"url":"https://api.github.com/repos/ipfs/go-ipfs/pulls/1385","id":37913802,"html_url":"https://github.com/ipfs/go-ipfs/pull/1385","diff_url":"https://github.com/ipfs/go-ipfs/pull/1385.diff","patch_url":"https://github.com/ipfs/go-ipfs/pull/1385.patch","issue_url":"https://api.github.com/repos/ipfs/go-ipfs/issues/1385","number":1385,"state":"open","locked":false,"title":" Cleanup ctxgroup goprocess","user":{"login":"rht","id":395821,"avatar_url":"https://avatars.githubusercontent.com/u/395821?v=3","gravatar_id":"","url":"https://api.github.com/users/rht","html_url":"https://github.com/rht","followers_url":"https://api.github.com/users/rht/followers","following_url":"https://api.github.com/users/rht/following{/other_user}","gists_url":"https://api.github.com/users/rht/gists{/gist_id}","starred_url":"https://api.github.com/users/rht/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rht/subscriptions","organizations_url":"https://api.github.com/users/rht/orgs","repos_url":"https://api.github.com/users/rht/repos","events_url":"https://api.github.com/users/rht/events{/privacy}","received_events_url":"https://api.github.com/users/rht/received_events","type":"User","site_admin":false},"body":"Close #1030 \r\n\r\nPending waiting for goprocess to have `SetTeardown()`","created_at":"2015-06-17T15:30:24Z","updated_at":"2015-07-04T22:52:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"49b2e6a5ac4fb88a0b8921596d6359222874e02b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ipfs/go-ipfs/pulls/1385/commits","review_comments_url":"https://api.github.com/repos/ipfs/go-ipfs/pulls/1385/comments","review_comment_url":"https://api.github.com/repos/ipfs/go-ipfs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ipfs/go-ipfs/issues/1385/comments","statuses_url":"https://api.github.com/repos/ipfs/go-ipfs/statuses/4c741193a4132c42db81dd0eb52595643f03f3ea","head":{"label":"rht:cleanup-ctxgroup-goprocess","ref":"cleanup-ctxgroup-goprocess","sha":"4c741193a4132c42db81dd0eb52595643f03f3ea","user":{"login":"rht","id":395821,"avatar_url":"https://avatars.githubusercontent.com/u/395821?v=3","gravatar_id":"","url":"https://api.github.com/users/rht","html_url":"https://github.com/rht","followers_url":"https://api.github.com/users/rht/followers","following_url":"https://api.github.com/users/rht/following{/other_user}","gists_url":"https://api.github.com/users/rht/gists{/gist_id}","starred_url":"https://api.github.com/users/rht/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rht/subscriptions","organizations_url":"https://api.github.com/users/rht/orgs","repos_url":"https://api.github.com/users/rht/repos","events_url":"https://api.github.com/users/rht/events{/privacy}","received_events_url":"https://api.github.com/users/rht/received_events","type":"User","site_admin":false},"repo":{"id":35830700,"name":"go-ipfs","full_name":"rht/go-ipfs","owner":{"login":"rht","id":395821,"avatar_url":"https://avatars.githubusercontent.com/u/395821?v=3","gravatar_id":"","url":"https://api.github.com/users/rht","html_url":"https://github.com/rht","followers_url":"https://api.github.com/users/rht/followers","following_url":"https://api.github.com/users/rht/following{/other_user}","gists_url":"https://api.github.com/users/rht/gists{/gist_id}","starred_url":"https://api.github.com/users/rht/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rht/subscriptions","organizations_url":"https://api.github.com/users/rht/orgs","repos_url":"https://api.github.com/users/rht/repos","events_url":"https://api.github.com/users/rht/events{/privacy}","received_events_url":"https://api.github.com/users/rht/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rht/go-ipfs","description":"ipfs implementation in go","fork":true,"url":"https://api.github.com/repos/rht/go-ipfs","forks_url":"https://api.github.com/repos/rht/go-ipfs/forks","keys_url":"https://api.github.com/repos/rht/go-ipfs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rht/go-ipfs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rht/go-ipfs/teams","hooks_url":"https://api.github.com/repos/rht/go-ipfs/hooks","issue_events_url":"https://api.github.com/repos/rht/go-ipfs/issues/events{/number}","events_url":"https://api.github.com/repos/rht/go-ipfs/events","assignees_url":"https://api.github.com/repos/rht/go-ipfs/assignees{/user}","branches_url":"https://api.github.com/repos/rht/go-ipfs/branches{/branch}","tags_url":"https://api.github.com/repos/rht/go-ipfs/tags","blobs_url":"https://api.github.com/repos/rht/go-ipfs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rht/go-ipfs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rht/go-ipfs/git/refs{/sha}","trees_url":"https://api.github.com/repos/rht/go-ipfs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rht/go-ipfs/statuses/{sha}","languages_url":"https://api.github.com/repos/rht/go-ipfs/languages","stargazers_url":"https://api.github.com/repos/rht/go-ipfs/stargazers","contributors_url":"https://api.github.com/repos/rht/go-ipfs/contributors","subscribers_url":"https://api.github.com/repos/rht/go-ipfs/subscribers","subscription_url":"https://api.github.com/repos/rht/go-ipfs/subscription","commits_url":"https://api.github.com/repos/rht/go-ipfs/commits{/sha}","git_commits_url":"https://api.github.com/repos/rht/go-ipfs/git/commits{/sha}","comments_url":"https://api.github.com/repos/rht/go-ipfs/comments{/number}","issue_comment_url":"https://api.github.com/repos/rht/go-ipfs/issues/comments{/number}","contents_url":"https://api.github.com/repos/rht/go-ipfs/contents/{+path}","compare_url":"https://api.github.com/repos/rht/go-ipfs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rht/go-ipfs/merges","archive_url":"https://api.github.com/repos/rht/go-ipfs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rht/go-ipfs/downloads","issues_url":"https://api.github.com/repos/rht/go-ipfs/issues{/number}","pulls_url":"https://api.github.com/repos/rht/go-ipfs/pulls{/number}","milestones_url":"https://api.github.com/repos/rht/go-ipfs/milestones{/number}","notifications_url":"https://api.github.com/repos/rht/go-ipfs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rht/go-ipfs/labels{/name}","releases_url":"https://api.github.com/repos/rht/go-ipfs/releases{/id}","created_at":"2015-05-18T17:00:33Z","updated_at":"2015-05-18T17:00:35Z","pushed_at":"2015-07-04T18:47:16Z","git_url":"git://github.com/rht/go-ipfs.git","ssh_url":"git@github.com:rht/go-ipfs.git","clone_url":"https://github.com/rht/go-ipfs.git","svn_url":"https://github.com/rht/go-ipfs","homepage":"https://github.com/ipfs/ipfs","size":19235,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ipfs:master","ref":"master","sha":"224a9eb0b95d2a9aa8f64466d5f0ab5cc5a0b89d","user":{"login":"ipfs","id":10536621,"avatar_url":"https://avatars.githubusercontent.com/u/10536621?v=3","gravatar_id":"","url":"https://api.github.com/users/ipfs","html_url":"https://github.com/ipfs","followers_url":"https://api.github.com/users/ipfs/followers","following_url":"https://api.github.com/users/ipfs/following{/other_user}","gists_url":"https://api.github.com/users/ipfs/gists{/gist_id}","starred_url":"https://api.github.com/users/ipfs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ipfs/subscriptions","organizations_url":"https://api.github.com/users/ipfs/orgs","repos_url":"https://api.github.com/users/ipfs/repos","events_url":"https://api.github.com/users/ipfs/events{/privacy}","received_events_url":"https://api.github.com/users/ipfs/received_events","type":"Organization","site_admin":false},"repo":{"id":21233191,"name":"go-ipfs","full_name":"ipfs/go-ipfs","owner":{"login":"ipfs","id":10536621,"avatar_url":"https://avatars.githubusercontent.com/u/10536621?v=3","gravatar_id":"","url":"https://api.github.com/users/ipfs","html_url":"https://github.com/ipfs","followers_url":"https://api.github.com/users/ipfs/followers","following_url":"https://api.github.com/users/ipfs/following{/other_user}","gists_url":"https://api.github.com/users/ipfs/gists{/gist_id}","starred_url":"https://api.github.com/users/ipfs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ipfs/subscriptions","organizations_url":"https://api.github.com/users/ipfs/orgs","repos_url":"https://api.github.com/users/ipfs/repos","events_url":"https://api.github.com/users/ipfs/events{/privacy}","received_events_url":"https://api.github.com/users/ipfs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ipfs/go-ipfs","description":"ipfs implementation in go","fork":false,"url":"https://api.github.com/repos/ipfs/go-ipfs","forks_url":"https://api.github.com/repos/ipfs/go-ipfs/forks","keys_url":"https://api.github.com/repos/ipfs/go-ipfs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ipfs/go-ipfs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ipfs/go-ipfs/teams","hooks_url":"https://api.github.com/repos/ipfs/go-ipfs/hooks","issue_events_url":"https://api.github.com/repos/ipfs/go-ipfs/issues/events{/number}","events_url":"https://api.github.com/repos/ipfs/go-ipfs/events","assignees_url":"https://api.github.com/repos/ipfs/go-ipfs/assignees{/user}","branches_url":"https://api.github.com/repos/ipfs/go-ipfs/branches{/branch}","tags_url":"https://api.github.com/repos/ipfs/go-ipfs/tags","blobs_url":"https://api.github.com/repos/ipfs/go-ipfs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ipfs/go-ipfs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ipfs/go-ipfs/git/refs{/sha}","trees_url":"https://api.github.com/repos/ipfs/go-ipfs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ipfs/go-ipfs/statuses/{sha}","languages_url":"https://api.github.com/repos/ipfs/go-ipfs/languages","stargazers_url":"https://api.github.com/repos/ipfs/go-ipfs/stargazers","contributors_url":"https://api.github.com/repos/ipfs/go-ipfs/contributors","subscribers_url":"https://api.github.com/repos/ipfs/go-ipfs/subscribers","subscription_url":"https://api.github.com/repos/ipfs/go-ipfs/subscription","commits_url":"https://api.github.com/repos/ipfs/go-ipfs/commits{/sha}","git_commits_url":"https://api.github.com/repos/ipfs/go-ipfs/git/commits{/sha}","comments_url":"https://api.github.com/repos/ipfs/go-ipfs/comments{/number}","issue_comment_url":"https://api.github.com/repos/ipfs/go-ipfs/issues/comments{/number}","contents_url":"https://api.github.com/repos/ipfs/go-ipfs/contents/{+path}","compare_url":"https://api.github.com/repos/ipfs/go-ipfs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ipfs/go-ipfs/merges","archive_url":"https://api.github.com/repos/ipfs/go-ipfs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ipfs/go-ipfs/downloads","issues_url":"https://api.github.com/repos/ipfs/go-ipfs/issues{/number}","pulls_url":"https://api.github.com/repos/ipfs/go-ipfs/pulls{/number}","milestones_url":"https://api.github.com/repos/ipfs/go-ipfs/milestones{/number}","notifications_url":"https://api.github.com/repos/ipfs/go-ipfs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ipfs/go-ipfs/labels{/name}","releases_url":"https://api.github.com/repos/ipfs/go-ipfs/releases{/id}","created_at":"2014-06-26T08:14:34Z","updated_at":"2015-07-04T16:54:03Z","pushed_at":"2015-07-04T18:47:16Z","git_url":"git://github.com/ipfs/go-ipfs.git","ssh_url":"git@github.com:ipfs/go-ipfs.git","clone_url":"https://github.com/ipfs/go-ipfs.git","svn_url":"https://github.com/ipfs/go-ipfs","homepage":"https://github.com/ipfs/ipfs","size":33094,"stargazers_count":627,"watchers_count":627,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":111,"mirror_url":null,"open_issues_count":288,"forks":111,"open_issues":288,"watchers":627,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ipfs/go-ipfs/pulls/1385"},"html":{"href":"https://github.com/ipfs/go-ipfs/pull/1385"},"issue":{"href":"https://api.github.com/repos/ipfs/go-ipfs/issues/1385"},"comments":{"href":"https://api.github.com/repos/ipfs/go-ipfs/issues/1385/comments"},"review_comments":{"href":"https://api.github.com/repos/ipfs/go-ipfs/pulls/1385/comments"},"review_comment":{"href":"https://api.github.com/repos/ipfs/go-ipfs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ipfs/go-ipfs/pulls/1385/commits"},"statuses":{"href":"https://api.github.com/repos/ipfs/go-ipfs/statuses/4c741193a4132c42db81dd0eb52595643f03f3ea"}}}}