{"action":"created","comment":{"url":"https://api.github.com/repos/pingcap/grpc-rs/pulls/comments/208986149","pull_request_review_id":144911003,"id":208986149,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwODk4NjE0OQ==","diff_hunk":"@@ -339,46 +350,55 @@ mod secure_server {\n     }\n }\n \n-pub struct Inner {\n-    env: Arc<Environment>,\n+struct ServerCore {\n     server: *mut GrpcServer,\n     bind_addrs: Vec<(String, u16)>,\n     slots_per_cq: usize,\n     shutdown: AtomicBool,\n-    handlers: HashMap<&'static [u8], Handler>,\n }\n \n-impl Inner {\n-    /// Get the handler for the requested method path.\n-    pub fn get_handler(&self, method: &[u8]) -> Option<&Handler> {\n-        self.handlers.get(method)\n+impl Drop for ServerCore {\n+    fn drop(&mut self) {\n+        unsafe { grpc_sys::grpc_server_destroy(self.server) }\n     }\n }\n \n-impl Debug for Inner {\n-    fn fmt(&self, f: &mut Formatter) -> fmt::Result {\n-        write!(f, \"Server {:?}\", self.bind_addrs)\n-    }\n+unsafe impl Send for ServerCore {}\n+unsafe impl Sync for ServerCore {}\n+\n+pub type BoxHandler = Box<CloneableHandler>;\n+\n+#[derive(Clone)]\n+pub struct RequestCallContext {\n+    server: Arc<ServerCore>,\n+    registry: Arc<HashMap<&'static [u8], BoxHandler>>,\n }\n \n-impl Drop for Inner {\n-    fn drop(&mut self) {\n-        unsafe { grpc_sys::grpc_server_destroy(self.server) }\n+impl RequestCallContext {\n+    /// Users should gurantee the method is always called from the same thread.","path":"src/server.rs","position":224,"original_position":224,"commit_id":"a116938798d13cde2a080a384d66264a0c05e78f","original_commit_id":"a116938798d13cde2a080a384d66264a0c05e78f","user":{"login":"Hoverbear","id":130903,"node_id":"MDQ6VXNlcjEzMDkwMw==","avatar_url":"https://avatars3.githubusercontent.com/u/130903?v=4","gravatar_id":"","url":"https://api.github.com/users/Hoverbear","html_url":"https://github.com/Hoverbear","followers_url":"https://api.github.com/users/Hoverbear/followers","following_url":"https://api.github.com/users/Hoverbear/following{/other_user}","gists_url":"https://api.github.com/users/Hoverbear/gists{/gist_id}","starred_url":"https://api.github.com/users/Hoverbear/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hoverbear/subscriptions","organizations_url":"https://api.github.com/users/Hoverbear/orgs","repos_url":"https://api.github.com/users/Hoverbear/repos","events_url":"https://api.github.com/users/Hoverbear/events{/privacy}","received_events_url":"https://api.github.com/users/Hoverbear/received_events","type":"User","site_admin":false},"body":"`guarantee`\r\n\r\nOne way to enforce this is to have the type change to a non-`Send` type after this function is called.","created_at":"2018-08-09T15:58:20Z","updated_at":"2018-08-09T15:58:20Z","html_url":"https://github.com/pingcap/grpc-rs/pull/216#discussion_r208986149","pull_request_url":"https://api.github.com/repos/pingcap/grpc-rs/pulls/216","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/pingcap/grpc-rs/pulls/comments/208986149"},"html":{"href":"https://github.com/pingcap/grpc-rs/pull/216#discussion_r208986149"},"pull_request":{"href":"https://api.github.com/repos/pingcap/grpc-rs/pulls/216"}}},"pull_request":{"url":"https://api.github.com/repos/pingcap/grpc-rs/pulls/216","id":207024538,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA3MDI0NTM4","html_url":"https://github.com/pingcap/grpc-rs/pull/216","diff_url":"https://github.com/pingcap/grpc-rs/pull/216.diff","patch_url":"https://github.com/pingcap/grpc-rs/pull/216.patch","issue_url":"https://api.github.com/repos/pingcap/grpc-rs/issues/216","number":216,"state":"open","locked":false,"title":"*: fix soundness of service handler","user":{"login":"BusyJay","id":1701473,"node_id":"MDQ6VXNlcjE3MDE0NzM=","avatar_url":"https://avatars3.githubusercontent.com/u/1701473?v=4","gravatar_id":"","url":"https://api.github.com/users/BusyJay","html_url":"https://github.com/BusyJay","followers_url":"https://api.github.com/users/BusyJay/followers","following_url":"https://api.github.com/users/BusyJay/following{/other_user}","gists_url":"https://api.github.com/users/BusyJay/gists{/gist_id}","starred_url":"https://api.github.com/users/BusyJay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BusyJay/subscriptions","organizations_url":"https://api.github.com/users/BusyJay/orgs","repos_url":"https://api.github.com/users/BusyJay/repos","events_url":"https://api.github.com/users/BusyJay/events{/privacy}","received_events_url":"https://api.github.com/users/BusyJay/received_events","type":"User","site_admin":false},"body":"We use Send + Clone pattern to achieve concurrency without lock.\r\nHowever our service handler registry treat them as if it's Send + Sync,\r\nwhich will lead to data race.","created_at":"2018-08-08T14:19:45Z","updated_at":"2018-08-09T15:58:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"942eb5cff1589e5f9853bb3502d2a6004c495e05","assignee":null,"assignees":[],"requested_reviewers":[{"login":"siddontang","id":1080370,"node_id":"MDQ6VXNlcjEwODAzNzA=","avatar_url":"https://avatars2.githubusercontent.com/u/1080370?v=4","gravatar_id":"","url":"https://api.github.com/users/siddontang","html_url":"https://github.com/siddontang","followers_url":"https://api.github.com/users/siddontang/followers","following_url":"https://api.github.com/users/siddontang/following{/other_user}","gists_url":"https://api.github.com/users/siddontang/gists{/gist_id}","starred_url":"https://api.github.com/users/siddontang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/siddontang/subscriptions","organizations_url":"https://api.github.com/users/siddontang/orgs","repos_url":"https://api.github.com/users/siddontang/repos","events_url":"https://api.github.com/users/siddontang/events{/privacy}","received_events_url":"https://api.github.com/users/siddontang/received_events","type":"User","site_admin":false},{"login":"overvenus","id":2150711,"node_id":"MDQ6VXNlcjIxNTA3MTE=","avatar_url":"https://avatars0.githubusercontent.com/u/2150711?v=4","gravatar_id":"","url":"https://api.github.com/users/overvenus","html_url":"https://github.com/overvenus","followers_url":"https://api.github.com/users/overvenus/followers","following_url":"https://api.github.com/users/overvenus/following{/other_user}","gists_url":"https://api.github.com/users/overvenus/gists{/gist_id}","starred_url":"https://api.github.com/users/overvenus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/overvenus/subscriptions","organizations_url":"https://api.github.com/users/overvenus/orgs","repos_url":"https://api.github.com/users/overvenus/repos","events_url":"https://api.github.com/users/overvenus/events{/privacy}","received_events_url":"https://api.github.com/users/overvenus/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/pingcap/grpc-rs/pulls/216/commits","review_comments_url":"https://api.github.com/repos/pingcap/grpc-rs/pulls/216/comments","review_comment_url":"https://api.github.com/repos/pingcap/grpc-rs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pingcap/grpc-rs/issues/216/comments","statuses_url":"https://api.github.com/repos/pingcap/grpc-rs/statuses/a116938798d13cde2a080a384d66264a0c05e78f","head":{"label":"pingcap:fix-sync-send","ref":"fix-sync-send","sha":"a116938798d13cde2a080a384d66264a0c05e78f","user":{"login":"pingcap","id":11855343,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExODU1MzQz","avatar_url":"https://avatars3.githubusercontent.com/u/11855343?v=4","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"repo":{"id":88956492,"node_id":"MDEwOlJlcG9zaXRvcnk4ODk1NjQ5Mg==","name":"grpc-rs","full_name":"pingcap/grpc-rs","owner":{"login":"pingcap","id":11855343,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExODU1MzQz","avatar_url":"https://avatars3.githubusercontent.com/u/11855343?v=4","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pingcap/grpc-rs","description":"The gRPC library for Rust built on C Core library and futures","fork":false,"url":"https://api.github.com/repos/pingcap/grpc-rs","forks_url":"https://api.github.com/repos/pingcap/grpc-rs/forks","keys_url":"https://api.github.com/repos/pingcap/grpc-rs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pingcap/grpc-rs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pingcap/grpc-rs/teams","hooks_url":"https://api.github.com/repos/pingcap/grpc-rs/hooks","issue_events_url":"https://api.github.com/repos/pingcap/grpc-rs/issues/events{/number}","events_url":"https://api.github.com/repos/pingcap/grpc-rs/events","assignees_url":"https://api.github.com/repos/pingcap/grpc-rs/assignees{/user}","branches_url":"https://api.github.com/repos/pingcap/grpc-rs/branches{/branch}","tags_url":"https://api.github.com/repos/pingcap/grpc-rs/tags","blobs_url":"https://api.github.com/repos/pingcap/grpc-rs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pingcap/grpc-rs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pingcap/grpc-rs/git/refs{/sha}","trees_url":"https://api.github.com/repos/pingcap/grpc-rs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pingcap/grpc-rs/statuses/{sha}","languages_url":"https://api.github.com/repos/pingcap/grpc-rs/languages","stargazers_url":"https://api.github.com/repos/pingcap/grpc-rs/stargazers","contributors_url":"https://api.github.com/repos/pingcap/grpc-rs/contributors","subscribers_url":"https://api.github.com/repos/pingcap/grpc-rs/subscribers","subscription_url":"https://api.github.com/repos/pingcap/grpc-rs/subscription","commits_url":"https://api.github.com/repos/pingcap/grpc-rs/commits{/sha}","git_commits_url":"https://api.github.com/repos/pingcap/grpc-rs/git/commits{/sha}","comments_url":"https://api.github.com/repos/pingcap/grpc-rs/comments{/number}","issue_comment_url":"https://api.github.com/repos/pingcap/grpc-rs/issues/comments{/number}","contents_url":"https://api.github.com/repos/pingcap/grpc-rs/contents/{+path}","compare_url":"https://api.github.com/repos/pingcap/grpc-rs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pingcap/grpc-rs/merges","archive_url":"https://api.github.com/repos/pingcap/grpc-rs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pingcap/grpc-rs/downloads","issues_url":"https://api.github.com/repos/pingcap/grpc-rs/issues{/number}","pulls_url":"https://api.github.com/repos/pingcap/grpc-rs/pulls{/number}","milestones_url":"https://api.github.com/repos/pingcap/grpc-rs/milestones{/number}","notifications_url":"https://api.github.com/repos/pingcap/grpc-rs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pingcap/grpc-rs/labels{/name}","releases_url":"https://api.github.com/repos/pingcap/grpc-rs/releases{/id}","deployments_url":"https://api.github.com/repos/pingcap/grpc-rs/deployments","created_at":"2017-04-21T07:41:57Z","updated_at":"2018-08-08T15:22:54Z","pushed_at":"2018-08-09T14:41:18Z","git_url":"git://github.com/pingcap/grpc-rs.git","ssh_url":"git@github.com:pingcap/grpc-rs.git","clone_url":"https://github.com/pingcap/grpc-rs.git","svn_url":"https://github.com/pingcap/grpc-rs","homepage":"","size":570,"stargazers_count":375,"watchers_count":375,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":51,"mirror_url":null,"archived":false,"open_issues_count":38,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":51,"open_issues":38,"watchers":375,"default_branch":"master"}},"base":{"label":"pingcap:master","ref":"master","sha":"1ecf788115c967657e358783ee853ed3e3154471","user":{"login":"pingcap","id":11855343,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExODU1MzQz","avatar_url":"https://avatars3.githubusercontent.com/u/11855343?v=4","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"repo":{"id":88956492,"node_id":"MDEwOlJlcG9zaXRvcnk4ODk1NjQ5Mg==","name":"grpc-rs","full_name":"pingcap/grpc-rs","owner":{"login":"pingcap","id":11855343,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExODU1MzQz","avatar_url":"https://avatars3.githubusercontent.com/u/11855343?v=4","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pingcap/grpc-rs","description":"The gRPC library for Rust built on C Core library and futures","fork":false,"url":"https://api.github.com/repos/pingcap/grpc-rs","forks_url":"https://api.github.com/repos/pingcap/grpc-rs/forks","keys_url":"https://api.github.com/repos/pingcap/grpc-rs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pingcap/grpc-rs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pingcap/grpc-rs/teams","hooks_url":"https://api.github.com/repos/pingcap/grpc-rs/hooks","issue_events_url":"https://api.github.com/repos/pingcap/grpc-rs/issues/events{/number}","events_url":"https://api.github.com/repos/pingcap/grpc-rs/events","assignees_url":"https://api.github.com/repos/pingcap/grpc-rs/assignees{/user}","branches_url":"https://api.github.com/repos/pingcap/grpc-rs/branches{/branch}","tags_url":"https://api.github.com/repos/pingcap/grpc-rs/tags","blobs_url":"https://api.github.com/repos/pingcap/grpc-rs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pingcap/grpc-rs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pingcap/grpc-rs/git/refs{/sha}","trees_url":"https://api.github.com/repos/pingcap/grpc-rs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pingcap/grpc-rs/statuses/{sha}","languages_url":"https://api.github.com/repos/pingcap/grpc-rs/languages","stargazers_url":"https://api.github.com/repos/pingcap/grpc-rs/stargazers","contributors_url":"https://api.github.com/repos/pingcap/grpc-rs/contributors","subscribers_url":"https://api.github.com/repos/pingcap/grpc-rs/subscribers","subscription_url":"https://api.github.com/repos/pingcap/grpc-rs/subscription","commits_url":"https://api.github.com/repos/pingcap/grpc-rs/commits{/sha}","git_commits_url":"https://api.github.com/repos/pingcap/grpc-rs/git/commits{/sha}","comments_url":"https://api.github.com/repos/pingcap/grpc-rs/comments{/number}","issue_comment_url":"https://api.github.com/repos/pingcap/grpc-rs/issues/comments{/number}","contents_url":"https://api.github.com/repos/pingcap/grpc-rs/contents/{+path}","compare_url":"https://api.github.com/repos/pingcap/grpc-rs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pingcap/grpc-rs/merges","archive_url":"https://api.github.com/repos/pingcap/grpc-rs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pingcap/grpc-rs/downloads","issues_url":"https://api.github.com/repos/pingcap/grpc-rs/issues{/number}","pulls_url":"https://api.github.com/repos/pingcap/grpc-rs/pulls{/number}","milestones_url":"https://api.github.com/repos/pingcap/grpc-rs/milestones{/number}","notifications_url":"https://api.github.com/repos/pingcap/grpc-rs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pingcap/grpc-rs/labels{/name}","releases_url":"https://api.github.com/repos/pingcap/grpc-rs/releases{/id}","deployments_url":"https://api.github.com/repos/pingcap/grpc-rs/deployments","created_at":"2017-04-21T07:41:57Z","updated_at":"2018-08-08T15:22:54Z","pushed_at":"2018-08-09T14:41:18Z","git_url":"git://github.com/pingcap/grpc-rs.git","ssh_url":"git@github.com:pingcap/grpc-rs.git","clone_url":"https://github.com/pingcap/grpc-rs.git","svn_url":"https://github.com/pingcap/grpc-rs","homepage":"","size":570,"stargazers_count":375,"watchers_count":375,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":51,"mirror_url":null,"archived":false,"open_issues_count":38,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":51,"open_issues":38,"watchers":375,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pingcap/grpc-rs/pulls/216"},"html":{"href":"https://github.com/pingcap/grpc-rs/pull/216"},"issue":{"href":"https://api.github.com/repos/pingcap/grpc-rs/issues/216"},"comments":{"href":"https://api.github.com/repos/pingcap/grpc-rs/issues/216/comments"},"review_comments":{"href":"https://api.github.com/repos/pingcap/grpc-rs/pulls/216/comments"},"review_comment":{"href":"https://api.github.com/repos/pingcap/grpc-rs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pingcap/grpc-rs/pulls/216/commits"},"statuses":{"href":"https://api.github.com/repos/pingcap/grpc-rs/statuses/a116938798d13cde2a080a384d66264a0c05e78f"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"Hoverbear"}}