{"action":"created","comment":{"url":"https://api.github.com/repos/keybase/gregor/pulls/comments/59438037","id":59438037,"diff_hunk":"@@ -106,28 +129,44 @@ func (c *connection) startRPCServer() <-chan error {\n \tfor _, prot := range prots {\n \t\tlog.Printf(\"registering protocol %s\", prot.Name)\n \t\tif err := srv.Register(prot); err != nil {\n-\t\t\terrCh := make(chan error, 1)\n-\t\t\terrCh <- err\n-\t\t\treturn errCh\n+\t\t\treturn err\n \t\t}\n \t}\n \n-\treturn srv.RunAsync()\n+\tcloseCh := make(chan error, 1)\n+\tgo func() {\n+\t\terr := srv.Run()\n+\t\tcloseCh <- err\n+\t}()\n+\tc.closeCh = closeCh\n+\treturn nil\n }\n \n func (c *connection) startAuthentication() error {\n-\terr := <-c.authCh\n-\tif err != nil {\n+\tselect {\n+\tcase err := <-c.closeCh:\n+\t\t// Always non-nil.\n \t\treturn err\n+\n+\tcase r := <-c.authCh:\n+\t\tif r.err != nil {\n+\t\t\treturn r.err\n+\t\t}\n+\n+\t\tif r.res.Uid == nil {\n+\t\t\treturn ErrBadUID\n+\t\t}\n+\n+\t\tc.tok = r.tok\n+\t\tc.uid = r.res.Uid\n+\t\tc.sid = r.res.Sid\n+\t\tc.lastAuthed = r.time\n+\t\treturn nil\n \t}\n-\tif c.uid == nil {\n-\t\treturn ErrBadUID\n-\t}\n-\treturn nil\n }\n \n func (c *connection) close() {\n-\tclose(c.authCh)\n+\t// Should trigger the c.closeCh case in startAuthentication.","path":"rpc/connection.go","position":139,"original_position":139,"commit_id":"debfbb9b251412f6602841d4e7c6a4141f8d4a43","original_commit_id":"debfbb9b251412f6602841d4e7c6a4141f8d4a43","user":{"login":"jacobhaven","id":95305,"avatar_url":"https://avatars.githubusercontent.com/u/95305?v=3","gravatar_id":"","url":"https://api.github.com/users/jacobhaven","html_url":"https://github.com/jacobhaven","followers_url":"https://api.github.com/users/jacobhaven/followers","following_url":"https://api.github.com/users/jacobhaven/following{/other_user}","gists_url":"https://api.github.com/users/jacobhaven/gists{/gist_id}","starred_url":"https://api.github.com/users/jacobhaven/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacobhaven/subscriptions","organizations_url":"https://api.github.com/users/jacobhaven/orgs","repos_url":"https://api.github.com/users/jacobhaven/repos","events_url":"https://api.github.com/users/jacobhaven/events{/privacy}","received_events_url":"https://api.github.com/users/jacobhaven/received_events","type":"User","site_admin":false},"body":"It doesn't? You need to `close(c.closeCh)`. That will set `err=nil`, though.","created_at":"2016-04-12T19:27:17Z","updated_at":"2016-04-12T19:27:17Z","html_url":"https://github.com/keybase/gregor/pull/27#discussion_r59438037","pull_request_url":"https://api.github.com/repos/keybase/gregor/pulls/27","_links":{"self":{"href":"https://api.github.com/repos/keybase/gregor/pulls/comments/59438037"},"html":{"href":"https://github.com/keybase/gregor/pull/27#discussion_r59438037"},"pull_request":{"href":"https://api.github.com/repos/keybase/gregor/pulls/27"}}},"pull_request":{"url":"https://api.github.com/repos/keybase/gregor/pulls/27","id":66208936,"html_url":"https://github.com/keybase/gregor/pull/27","diff_url":"https://github.com/keybase/gregor/pull/27.diff","patch_url":"https://github.com/keybase/gregor/pull/27.patch","issue_url":"https://api.github.com/repos/keybase/gregor/issues/27","number":27,"state":"open","locked":false,"title":"Make connection use rpc.Server.Run()","user":{"login":"akalin-keybase","id":13270622,"avatar_url":"https://avatars.githubusercontent.com/u/13270622?v=3","gravatar_id":"","url":"https://api.github.com/users/akalin-keybase","html_url":"https://github.com/akalin-keybase","followers_url":"https://api.github.com/users/akalin-keybase/followers","following_url":"https://api.github.com/users/akalin-keybase/following{/other_user}","gists_url":"https://api.github.com/users/akalin-keybase/gists{/gist_id}","starred_url":"https://api.github.com/users/akalin-keybase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akalin-keybase/subscriptions","organizations_url":"https://api.github.com/users/akalin-keybase/orgs","repos_url":"https://api.github.com/users/akalin-keybase/repos","events_url":"https://api.github.com/users/akalin-keybase/events{/privacy}","received_events_url":"https://api.github.com/users/akalin-keybase/received_events","type":"User","site_admin":false},"body":"Also clean up some latent race conditions.","created_at":"2016-04-12T18:54:54Z","updated_at":"2016-04-12T19:27:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dcdf4c7593506938d6d5bc708ae038e43a31fae8","assignee":{"login":"jacobhaven","id":95305,"avatar_url":"https://avatars.githubusercontent.com/u/95305?v=3","gravatar_id":"","url":"https://api.github.com/users/jacobhaven","html_url":"https://github.com/jacobhaven","followers_url":"https://api.github.com/users/jacobhaven/followers","following_url":"https://api.github.com/users/jacobhaven/following{/other_user}","gists_url":"https://api.github.com/users/jacobhaven/gists{/gist_id}","starred_url":"https://api.github.com/users/jacobhaven/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacobhaven/subscriptions","organizations_url":"https://api.github.com/users/jacobhaven/orgs","repos_url":"https://api.github.com/users/jacobhaven/repos","events_url":"https://api.github.com/users/jacobhaven/events{/privacy}","received_events_url":"https://api.github.com/users/jacobhaven/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/keybase/gregor/pulls/27/commits","review_comments_url":"https://api.github.com/repos/keybase/gregor/pulls/27/comments","review_comment_url":"https://api.github.com/repos/keybase/gregor/pulls/comments{/number}","comments_url":"https://api.github.com/repos/keybase/gregor/issues/27/comments","statuses_url":"https://api.github.com/repos/keybase/gregor/statuses/debfbb9b251412f6602841d4e7c6a4141f8d4a43","head":{"label":"keybase:server-run","ref":"server-run","sha":"debfbb9b251412f6602841d4e7c6a4141f8d4a43","user":{"login":"keybase","id":5400834,"avatar_url":"https://avatars.githubusercontent.com/u/5400834?v=3","gravatar_id":"","url":"https://api.github.com/users/keybase","html_url":"https://github.com/keybase","followers_url":"https://api.github.com/users/keybase/followers","following_url":"https://api.github.com/users/keybase/following{/other_user}","gists_url":"https://api.github.com/users/keybase/gists{/gist_id}","starred_url":"https://api.github.com/users/keybase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keybase/subscriptions","organizations_url":"https://api.github.com/users/keybase/orgs","repos_url":"https://api.github.com/users/keybase/repos","events_url":"https://api.github.com/users/keybase/events{/privacy}","received_events_url":"https://api.github.com/users/keybase/received_events","type":"Organization","site_admin":false},"repo":{"id":53508286,"name":"gregor","full_name":"keybase/gregor","owner":{"login":"keybase","id":5400834,"avatar_url":"https://avatars.githubusercontent.com/u/5400834?v=3","gravatar_id":"","url":"https://api.github.com/users/keybase","html_url":"https://github.com/keybase","followers_url":"https://api.github.com/users/keybase/followers","following_url":"https://api.github.com/users/keybase/following{/other_user}","gists_url":"https://api.github.com/users/keybase/gists{/gist_id}","starred_url":"https://api.github.com/users/keybase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keybase/subscriptions","organizations_url":"https://api.github.com/users/keybase/orgs","repos_url":"https://api.github.com/users/keybase/repos","events_url":"https://api.github.com/users/keybase/events{/privacy}","received_events_url":"https://api.github.com/users/keybase/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/keybase/gregor","description":"A simple state-sync service for UX notifications","fork":false,"url":"https://api.github.com/repos/keybase/gregor","forks_url":"https://api.github.com/repos/keybase/gregor/forks","keys_url":"https://api.github.com/repos/keybase/gregor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/keybase/gregor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/keybase/gregor/teams","hooks_url":"https://api.github.com/repos/keybase/gregor/hooks","issue_events_url":"https://api.github.com/repos/keybase/gregor/issues/events{/number}","events_url":"https://api.github.com/repos/keybase/gregor/events","assignees_url":"https://api.github.com/repos/keybase/gregor/assignees{/user}","branches_url":"https://api.github.com/repos/keybase/gregor/branches{/branch}","tags_url":"https://api.github.com/repos/keybase/gregor/tags","blobs_url":"https://api.github.com/repos/keybase/gregor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/keybase/gregor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/keybase/gregor/git/refs{/sha}","trees_url":"https://api.github.com/repos/keybase/gregor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/keybase/gregor/statuses/{sha}","languages_url":"https://api.github.com/repos/keybase/gregor/languages","stargazers_url":"https://api.github.com/repos/keybase/gregor/stargazers","contributors_url":"https://api.github.com/repos/keybase/gregor/contributors","subscribers_url":"https://api.github.com/repos/keybase/gregor/subscribers","subscription_url":"https://api.github.com/repos/keybase/gregor/subscription","commits_url":"https://api.github.com/repos/keybase/gregor/commits{/sha}","git_commits_url":"https://api.github.com/repos/keybase/gregor/git/commits{/sha}","comments_url":"https://api.github.com/repos/keybase/gregor/comments{/number}","issue_comment_url":"https://api.github.com/repos/keybase/gregor/issues/comments{/number}","contents_url":"https://api.github.com/repos/keybase/gregor/contents/{+path}","compare_url":"https://api.github.com/repos/keybase/gregor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/keybase/gregor/merges","archive_url":"https://api.github.com/repos/keybase/gregor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/keybase/gregor/downloads","issues_url":"https://api.github.com/repos/keybase/gregor/issues{/number}","pulls_url":"https://api.github.com/repos/keybase/gregor/pulls{/number}","milestones_url":"https://api.github.com/repos/keybase/gregor/milestones{/number}","notifications_url":"https://api.github.com/repos/keybase/gregor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/keybase/gregor/labels{/name}","releases_url":"https://api.github.com/repos/keybase/gregor/releases{/id}","deployments_url":"https://api.github.com/repos/keybase/gregor/deployments","created_at":"2016-03-09T15:23:03Z","updated_at":"2016-04-05T21:33:00Z","pushed_at":"2016-04-12T18:54:54Z","git_url":"git://github.com/keybase/gregor.git","ssh_url":"git@github.com:keybase/gregor.git","clone_url":"https://github.com/keybase/gregor.git","svn_url":"https://github.com/keybase/gregor","homepage":null,"size":5554,"stargazers_count":1,"watchers_count":1,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":1,"default_branch":"master"}},"base":{"label":"keybase:master","ref":"master","sha":"8786a417491e70b31a44e797577d334534c83c7b","user":{"login":"keybase","id":5400834,"avatar_url":"https://avatars.githubusercontent.com/u/5400834?v=3","gravatar_id":"","url":"https://api.github.com/users/keybase","html_url":"https://github.com/keybase","followers_url":"https://api.github.com/users/keybase/followers","following_url":"https://api.github.com/users/keybase/following{/other_user}","gists_url":"https://api.github.com/users/keybase/gists{/gist_id}","starred_url":"https://api.github.com/users/keybase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keybase/subscriptions","organizations_url":"https://api.github.com/users/keybase/orgs","repos_url":"https://api.github.com/users/keybase/repos","events_url":"https://api.github.com/users/keybase/events{/privacy}","received_events_url":"https://api.github.com/users/keybase/received_events","type":"Organization","site_admin":false},"repo":{"id":53508286,"name":"gregor","full_name":"keybase/gregor","owner":{"login":"keybase","id":5400834,"avatar_url":"https://avatars.githubusercontent.com/u/5400834?v=3","gravatar_id":"","url":"https://api.github.com/users/keybase","html_url":"https://github.com/keybase","followers_url":"https://api.github.com/users/keybase/followers","following_url":"https://api.github.com/users/keybase/following{/other_user}","gists_url":"https://api.github.com/users/keybase/gists{/gist_id}","starred_url":"https://api.github.com/users/keybase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keybase/subscriptions","organizations_url":"https://api.github.com/users/keybase/orgs","repos_url":"https://api.github.com/users/keybase/repos","events_url":"https://api.github.com/users/keybase/events{/privacy}","received_events_url":"https://api.github.com/users/keybase/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/keybase/gregor","description":"A simple state-sync service for UX notifications","fork":false,"url":"https://api.github.com/repos/keybase/gregor","forks_url":"https://api.github.com/repos/keybase/gregor/forks","keys_url":"https://api.github.com/repos/keybase/gregor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/keybase/gregor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/keybase/gregor/teams","hooks_url":"https://api.github.com/repos/keybase/gregor/hooks","issue_events_url":"https://api.github.com/repos/keybase/gregor/issues/events{/number}","events_url":"https://api.github.com/repos/keybase/gregor/events","assignees_url":"https://api.github.com/repos/keybase/gregor/assignees{/user}","branches_url":"https://api.github.com/repos/keybase/gregor/branches{/branch}","tags_url":"https://api.github.com/repos/keybase/gregor/tags","blobs_url":"https://api.github.com/repos/keybase/gregor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/keybase/gregor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/keybase/gregor/git/refs{/sha}","trees_url":"https://api.github.com/repos/keybase/gregor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/keybase/gregor/statuses/{sha}","languages_url":"https://api.github.com/repos/keybase/gregor/languages","stargazers_url":"https://api.github.com/repos/keybase/gregor/stargazers","contributors_url":"https://api.github.com/repos/keybase/gregor/contributors","subscribers_url":"https://api.github.com/repos/keybase/gregor/subscribers","subscription_url":"https://api.github.com/repos/keybase/gregor/subscription","commits_url":"https://api.github.com/repos/keybase/gregor/commits{/sha}","git_commits_url":"https://api.github.com/repos/keybase/gregor/git/commits{/sha}","comments_url":"https://api.github.com/repos/keybase/gregor/comments{/number}","issue_comment_url":"https://api.github.com/repos/keybase/gregor/issues/comments{/number}","contents_url":"https://api.github.com/repos/keybase/gregor/contents/{+path}","compare_url":"https://api.github.com/repos/keybase/gregor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/keybase/gregor/merges","archive_url":"https://api.github.com/repos/keybase/gregor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/keybase/gregor/downloads","issues_url":"https://api.github.com/repos/keybase/gregor/issues{/number}","pulls_url":"https://api.github.com/repos/keybase/gregor/pulls{/number}","milestones_url":"https://api.github.com/repos/keybase/gregor/milestones{/number}","notifications_url":"https://api.github.com/repos/keybase/gregor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/keybase/gregor/labels{/name}","releases_url":"https://api.github.com/repos/keybase/gregor/releases{/id}","deployments_url":"https://api.github.com/repos/keybase/gregor/deployments","created_at":"2016-03-09T15:23:03Z","updated_at":"2016-04-05T21:33:00Z","pushed_at":"2016-04-12T18:54:54Z","git_url":"git://github.com/keybase/gregor.git","ssh_url":"git@github.com:keybase/gregor.git","clone_url":"https://github.com/keybase/gregor.git","svn_url":"https://github.com/keybase/gregor","homepage":null,"size":5554,"stargazers_count":1,"watchers_count":1,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/keybase/gregor/pulls/27"},"html":{"href":"https://github.com/keybase/gregor/pull/27"},"issue":{"href":"https://api.github.com/repos/keybase/gregor/issues/27"},"comments":{"href":"https://api.github.com/repos/keybase/gregor/issues/27/comments"},"review_comments":{"href":"https://api.github.com/repos/keybase/gregor/pulls/27/comments"},"review_comment":{"href":"https://api.github.com/repos/keybase/gregor/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/keybase/gregor/pulls/27/commits"},"statuses":{"href":"https://api.github.com/repos/keybase/gregor/statuses/debfbb9b251412f6602841d4e7c6a4141f8d4a43"}}}}