{"action":"created","comment":{"url":"https://api.github.com/repos/jbenet/go-peerstream/pulls/comments/46409309","id":46409309,"diff_hunk":"@@ -118,12 +118,12 @@ func (c *Conn) Streams() []*Stream {\n // Close closes this connection\n func (c *Conn) Close() error {\n \tc.closeLock.Lock()\n-\tdefer c.closeLock.Unlock()\n-\n \tif c.closed {\n+\t\tc.closeLock.Unlock()","path":"conn.go","position":7,"original_position":7,"commit_id":"b4a7b5a90818d6b8f61f297e06bed6674d12c547","original_commit_id":"b4a7b5a90818d6b8f61f297e06bed6674d12c547","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":"this wont work because then a second caller could exit way before the Conn is _actually closed_. maybe make them wait?\r\n\r\n```go\r\nc.closeLock.Lock()\r\nif c.closed {\r\n  c.closeLock.Unlock()\r\n  <-c.closeChan\r\n  return c.closeErr\r\n}\r\nc.closed = true\r\nc.closeLock.Unlock()\r\ndefer func() {\r\n  c.closeChan<- struct{}{}\r\n}()\r\n```\r\n\r\nor use https://github.com/jbenet/goprocess and avoid the close lock madness alltogether, which also gives us nice errors. (goproc doesnt have the UX bugs, it's goproc/ratelimit that has caused the problems in the last few months)","created_at":"2015-12-02T12:44:43Z","updated_at":"2015-12-02T12:44:43Z","html_url":"https://github.com/jbenet/go-peerstream/pull/21#discussion_r46409309","pull_request_url":"https://api.github.com/repos/jbenet/go-peerstream/pulls/21","_links":{"self":{"href":"https://api.github.com/repos/jbenet/go-peerstream/pulls/comments/46409309"},"html":{"href":"https://github.com/jbenet/go-peerstream/pull/21#discussion_r46409309"},"pull_request":{"href":"https://api.github.com/repos/jbenet/go-peerstream/pulls/21"}}},"pull_request":{"url":"https://api.github.com/repos/jbenet/go-peerstream/pulls/21","id":52296951,"html_url":"https://github.com/jbenet/go-peerstream/pull/21","diff_url":"https://github.com/jbenet/go-peerstream/pull/21.diff","patch_url":"https://github.com/jbenet/go-peerstream/pull/21.patch","issue_url":"https://api.github.com/repos/jbenet/go-peerstream/issues/21","number":21,"state":"open","locked":false,"title":"Fix close deadlock","user":{"login":"whyrusleeping","id":1243164,"avatar_url":"https://avatars.githubusercontent.com/u/1243164?v=3","gravatar_id":"","url":"https://api.github.com/users/whyrusleeping","html_url":"https://github.com/whyrusleeping","followers_url":"https://api.github.com/users/whyrusleeping/followers","following_url":"https://api.github.com/users/whyrusleeping/following{/other_user}","gists_url":"https://api.github.com/users/whyrusleeping/gists{/gist_id}","starred_url":"https://api.github.com/users/whyrusleeping/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/whyrusleeping/subscriptions","organizations_url":"https://api.github.com/users/whyrusleeping/orgs","repos_url":"https://api.github.com/users/whyrusleeping/repos","events_url":"https://api.github.com/users/whyrusleeping/events{/privacy}","received_events_url":"https://api.github.com/users/whyrusleeping/received_events","type":"User","site_admin":false},"body":"There was a race condition, where upon closing a conn and all its child\r\nstreams, a (potential?) issue in the underlying transport library caused\r\nthe 'Close' call to hang, leading to deadlocks in the peerstream code.\r\n\r\nThis changes the lock to only be held during the closed'ness check, and\r\nshould protect go-peerstream users against issues (misunderstandings?)\r\nin the underlying transport libs.","created_at":"2015-12-01T18:35:09Z","updated_at":"2015-12-02T12:44:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6c982470d93084f9315b4bef85e9499d7d04bffc","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/jbenet/go-peerstream/pulls/21/commits","review_comments_url":"https://api.github.com/repos/jbenet/go-peerstream/pulls/21/comments","review_comment_url":"https://api.github.com/repos/jbenet/go-peerstream/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jbenet/go-peerstream/issues/21/comments","statuses_url":"https://api.github.com/repos/jbenet/go-peerstream/statuses/b4a7b5a90818d6b8f61f297e06bed6674d12c547","head":{"label":"jbenet:fix/race-lock","ref":"fix/race-lock","sha":"b4a7b5a90818d6b8f61f297e06bed6674d12c547","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},"repo":{"id":28001216,"name":"go-peerstream","full_name":"jbenet/go-peerstream","owner":{"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},"private":false,"html_url":"https://github.com/jbenet/go-peerstream","description":"p2p stream multi-multiplexing in Go (with https://github.com/docker/spdystream)","fork":false,"url":"https://api.github.com/repos/jbenet/go-peerstream","forks_url":"https://api.github.com/repos/jbenet/go-peerstream/forks","keys_url":"https://api.github.com/repos/jbenet/go-peerstream/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jbenet/go-peerstream/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jbenet/go-peerstream/teams","hooks_url":"https://api.github.com/repos/jbenet/go-peerstream/hooks","issue_events_url":"https://api.github.com/repos/jbenet/go-peerstream/issues/events{/number}","events_url":"https://api.github.com/repos/jbenet/go-peerstream/events","assignees_url":"https://api.github.com/repos/jbenet/go-peerstream/assignees{/user}","branches_url":"https://api.github.com/repos/jbenet/go-peerstream/branches{/branch}","tags_url":"https://api.github.com/repos/jbenet/go-peerstream/tags","blobs_url":"https://api.github.com/repos/jbenet/go-peerstream/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jbenet/go-peerstream/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jbenet/go-peerstream/git/refs{/sha}","trees_url":"https://api.github.com/repos/jbenet/go-peerstream/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jbenet/go-peerstream/statuses/{sha}","languages_url":"https://api.github.com/repos/jbenet/go-peerstream/languages","stargazers_url":"https://api.github.com/repos/jbenet/go-peerstream/stargazers","contributors_url":"https://api.github.com/repos/jbenet/go-peerstream/contributors","subscribers_url":"https://api.github.com/repos/jbenet/go-peerstream/subscribers","subscription_url":"https://api.github.com/repos/jbenet/go-peerstream/subscription","commits_url":"https://api.github.com/repos/jbenet/go-peerstream/commits{/sha}","git_commits_url":"https://api.github.com/repos/jbenet/go-peerstream/git/commits{/sha}","comments_url":"https://api.github.com/repos/jbenet/go-peerstream/comments{/number}","issue_comment_url":"https://api.github.com/repos/jbenet/go-peerstream/issues/comments{/number}","contents_url":"https://api.github.com/repos/jbenet/go-peerstream/contents/{+path}","compare_url":"https://api.github.com/repos/jbenet/go-peerstream/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jbenet/go-peerstream/merges","archive_url":"https://api.github.com/repos/jbenet/go-peerstream/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jbenet/go-peerstream/downloads","issues_url":"https://api.github.com/repos/jbenet/go-peerstream/issues{/number}","pulls_url":"https://api.github.com/repos/jbenet/go-peerstream/pulls{/number}","milestones_url":"https://api.github.com/repos/jbenet/go-peerstream/milestones{/number}","notifications_url":"https://api.github.com/repos/jbenet/go-peerstream/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jbenet/go-peerstream/labels{/name}","releases_url":"https://api.github.com/repos/jbenet/go-peerstream/releases{/id}","created_at":"2014-12-14T17:04:49Z","updated_at":"2015-11-05T17:28:58Z","pushed_at":"2015-12-01T18:35:09Z","git_url":"git://github.com/jbenet/go-peerstream.git","ssh_url":"git@github.com:jbenet/go-peerstream.git","clone_url":"https://github.com/jbenet/go-peerstream.git","svn_url":"https://github.com/jbenet/go-peerstream","homepage":"","size":1896,"stargazers_count":26,"watchers_count":26,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":3,"forks":8,"open_issues":3,"watchers":26,"default_branch":"master"}},"base":{"label":"jbenet:master","ref":"master","sha":"f90119e97e8be7b2bdd5e598067b0dc44df63381","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},"repo":{"id":28001216,"name":"go-peerstream","full_name":"jbenet/go-peerstream","owner":{"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},"private":false,"html_url":"https://github.com/jbenet/go-peerstream","description":"p2p stream multi-multiplexing in Go (with https://github.com/docker/spdystream)","fork":false,"url":"https://api.github.com/repos/jbenet/go-peerstream","forks_url":"https://api.github.com/repos/jbenet/go-peerstream/forks","keys_url":"https://api.github.com/repos/jbenet/go-peerstream/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jbenet/go-peerstream/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jbenet/go-peerstream/teams","hooks_url":"https://api.github.com/repos/jbenet/go-peerstream/hooks","issue_events_url":"https://api.github.com/repos/jbenet/go-peerstream/issues/events{/number}","events_url":"https://api.github.com/repos/jbenet/go-peerstream/events","assignees_url":"https://api.github.com/repos/jbenet/go-peerstream/assignees{/user}","branches_url":"https://api.github.com/repos/jbenet/go-peerstream/branches{/branch}","tags_url":"https://api.github.com/repos/jbenet/go-peerstream/tags","blobs_url":"https://api.github.com/repos/jbenet/go-peerstream/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jbenet/go-peerstream/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jbenet/go-peerstream/git/refs{/sha}","trees_url":"https://api.github.com/repos/jbenet/go-peerstream/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jbenet/go-peerstream/statuses/{sha}","languages_url":"https://api.github.com/repos/jbenet/go-peerstream/languages","stargazers_url":"https://api.github.com/repos/jbenet/go-peerstream/stargazers","contributors_url":"https://api.github.com/repos/jbenet/go-peerstream/contributors","subscribers_url":"https://api.github.com/repos/jbenet/go-peerstream/subscribers","subscription_url":"https://api.github.com/repos/jbenet/go-peerstream/subscription","commits_url":"https://api.github.com/repos/jbenet/go-peerstream/commits{/sha}","git_commits_url":"https://api.github.com/repos/jbenet/go-peerstream/git/commits{/sha}","comments_url":"https://api.github.com/repos/jbenet/go-peerstream/comments{/number}","issue_comment_url":"https://api.github.com/repos/jbenet/go-peerstream/issues/comments{/number}","contents_url":"https://api.github.com/repos/jbenet/go-peerstream/contents/{+path}","compare_url":"https://api.github.com/repos/jbenet/go-peerstream/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jbenet/go-peerstream/merges","archive_url":"https://api.github.com/repos/jbenet/go-peerstream/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jbenet/go-peerstream/downloads","issues_url":"https://api.github.com/repos/jbenet/go-peerstream/issues{/number}","pulls_url":"https://api.github.com/repos/jbenet/go-peerstream/pulls{/number}","milestones_url":"https://api.github.com/repos/jbenet/go-peerstream/milestones{/number}","notifications_url":"https://api.github.com/repos/jbenet/go-peerstream/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jbenet/go-peerstream/labels{/name}","releases_url":"https://api.github.com/repos/jbenet/go-peerstream/releases{/id}","created_at":"2014-12-14T17:04:49Z","updated_at":"2015-11-05T17:28:58Z","pushed_at":"2015-12-01T18:35:09Z","git_url":"git://github.com/jbenet/go-peerstream.git","ssh_url":"git@github.com:jbenet/go-peerstream.git","clone_url":"https://github.com/jbenet/go-peerstream.git","svn_url":"https://github.com/jbenet/go-peerstream","homepage":"","size":1896,"stargazers_count":26,"watchers_count":26,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":3,"forks":8,"open_issues":3,"watchers":26,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jbenet/go-peerstream/pulls/21"},"html":{"href":"https://github.com/jbenet/go-peerstream/pull/21"},"issue":{"href":"https://api.github.com/repos/jbenet/go-peerstream/issues/21"},"comments":{"href":"https://api.github.com/repos/jbenet/go-peerstream/issues/21/comments"},"review_comments":{"href":"https://api.github.com/repos/jbenet/go-peerstream/pulls/21/comments"},"review_comment":{"href":"https://api.github.com/repos/jbenet/go-peerstream/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jbenet/go-peerstream/pulls/21/commits"},"statuses":{"href":"https://api.github.com/repos/jbenet/go-peerstream/statuses/b4a7b5a90818d6b8f61f297e06bed6674d12c547"}}}}