{"action":"created","comment":{"url":"https://api.github.com/repos/apple/swift-nio/pulls/comments/181356122","pull_request_review_id":111966861,"id":181356122,"diff_hunk":"@@ -389,11 +421,22 @@ final class Selector<R: Registration> {\n             default:\n                 // If the registration is not in the Map anymore we deregistered it during the processing of whenReady(...). In this case just skip it.\n                 if let registration = registrations[Int(ev.data.fd)] {\n-                    try body(\n-                        SelectorEvent(\n-                            readable: (ev.events & Epoll.EPOLLIN.rawValue) != 0 || (ev.events & Epoll.EPOLLERR.rawValue) != 0 || (ev.events & Epoll.EPOLLRDHUP.rawValue) != 0,\n-                            writable: (ev.events & Epoll.EPOLLOUT.rawValue) != 0 || (ev.events & Epoll.EPOLLERR.rawValue) != 0 || (ev.events & Epoll.EPOLLRDHUP.rawValue) != 0,\n-                            registration: registration))\n+                    var selectorEvent: SelectorEventSet = ._none\n+                    if ev.events & Epoll.EPOLLIN.rawValue != 0 {\n+                        selectorEvent.formUnion(.read)\n+                    }\n+                    if ev.events & Epoll.EPOLLOUT.rawValue != 0 {\n+                        selectorEvent.formUnion(.write)\n+                    }\n+                    if ev.events & Epoll.EPOLLRDHUP.rawValue != 0 {\n+                        selectorEvent.formUnion(.readEOF)\n+                    }\n+                    if ev.events & Epoll.EPOLLHUP.rawValue != 0 || ev.events & Epoll.EPOLLERR.rawValue != 0 {\n+                        selectorEvent.formUnion(.reset)\n+                    }","path":"Sources/NIO/Selector.swift","position":450,"original_position":302,"commit_id":"c1bae21ef1f41a188675dafccbd2a040b74e67cf","original_commit_id":"46217d57f89a4ebc52461a0326be04e3ce5dc3a0","user":{"login":"Lukasa","id":1382556,"avatar_url":"https://avatars1.githubusercontent.com/u/1382556?v=4","gravatar_id":"","url":"https://api.github.com/users/Lukasa","html_url":"https://github.com/Lukasa","followers_url":"https://api.github.com/users/Lukasa/followers","following_url":"https://api.github.com/users/Lukasa/following{/other_user}","gists_url":"https://api.github.com/users/Lukasa/gists{/gist_id}","starred_url":"https://api.github.com/users/Lukasa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lukasa/subscriptions","organizations_url":"https://api.github.com/users/Lukasa/orgs","repos_url":"https://api.github.com/users/Lukasa/repos","events_url":"https://api.github.com/users/Lukasa/events{/privacy}","received_events_url":"https://api.github.com/users/Lukasa/received_events","type":"User","site_admin":false},"body":"Though actually I might think it should be an extension containing an initializer for `SelectorEventSet`, actually.","created_at":"2018-04-13T11:09:48Z","updated_at":"2018-04-13T11:12:00Z","html_url":"https://github.com/apple/swift-nio/pull/286#discussion_r181356122","pull_request_url":"https://api.github.com/repos/apple/swift-nio/pulls/286","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/apple/swift-nio/pulls/comments/181356122"},"html":{"href":"https://github.com/apple/swift-nio/pull/286#discussion_r181356122"},"pull_request":{"href":"https://api.github.com/repos/apple/swift-nio/pulls/286"}},"in_reply_to_id":180155040},"pull_request":{"url":"https://api.github.com/repos/apple/swift-nio/pulls/286","id":179774089,"html_url":"https://github.com/apple/swift-nio/pull/286","diff_url":"https://github.com/apple/swift-nio/pull/286.diff","patch_url":"https://github.com/apple/swift-nio/pull/286.patch","issue_url":"https://api.github.com/repos/apple/swift-nio/issues/286","number":286,"state":"open","locked":false,"title":"eagerly process input EOF/connection resets (fixes #277)","user":{"login":"weissi","id":624238,"avatar_url":"https://avatars2.githubusercontent.com/u/624238?v=4","gravatar_id":"","url":"https://api.github.com/users/weissi","html_url":"https://github.com/weissi","followers_url":"https://api.github.com/users/weissi/followers","following_url":"https://api.github.com/users/weissi/following{/other_user}","gists_url":"https://api.github.com/users/weissi/gists{/gist_id}","starred_url":"https://api.github.com/users/weissi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weissi/subscriptions","organizations_url":"https://api.github.com/users/weissi/orgs","repos_url":"https://api.github.com/users/weissi/repos","events_url":"https://api.github.com/users/weissi/events{/privacy}","received_events_url":"https://api.github.com/users/weissi/received_events","type":"User","site_admin":false},"body":"Motivation:\r\n\r\nWe had a number of problems:\r\n\r\n1. We wanted to lazily process input EOFs and connection resets only\r\n   when the user actually calls `read()`. On Linux however you cannot\r\n   unsubscribe from `EPOLLHUP` so that's not possible.\r\n2. Lazily processing input EOFs/connection resets wastes kernel\r\n   resources and that could potentially lead to a DOS\r\n3. The very low-level `Selector` interpreted the eventing mechanism's\r\n   events quite a lot so the `EventLoop`/`Channel` only ever saw\r\n   `readable` or `writable` without further information what exactly\r\n   happened.\r\n4. We completely ignored `EPOLLHUP` until now which on Unix Domain\r\n   Socket close leads to a 100% CPU spin (issue #277)\r\n\r\nModifications:\r\n\r\n- made the `Selector` interface richer, it now sends the following\r\n  events: `readable`, `writable`, `readEOF` (input EOF), `reset`\r\n  (connection reset or some error)\r\n- process input EOFs and connection resets/errors eagerly\r\n- change all tests which relied on using unconnected and unbound sockets\r\n  to user connected/bound ones as `epoll_wait` otherwise would keep\r\n  sending us a stream of `EPOLLHUP`s which would now lead to an eager\r\n  close\r\n\r\nResult:\r\n\r\n- most importantly: fixes #277\r\n- waste less kernel resources (by dealing with input EOFs/connection\r\n  resets eagerly)\r\n- bring kqueue/epoll more in line","created_at":"2018-04-05T19:30:46Z","updated_at":"2018-04-13T11:12:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"15a487b5deb446a9b737fa477b567104c8fb85f5","assignee":null,"assignees":[],"requested_reviewers":[{"login":"normanmaurer","id":439362,"avatar_url":"https://avatars3.githubusercontent.com/u/439362?v=4","gravatar_id":"","url":"https://api.github.com/users/normanmaurer","html_url":"https://github.com/normanmaurer","followers_url":"https://api.github.com/users/normanmaurer/followers","following_url":"https://api.github.com/users/normanmaurer/following{/other_user}","gists_url":"https://api.github.com/users/normanmaurer/gists{/gist_id}","starred_url":"https://api.github.com/users/normanmaurer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/normanmaurer/subscriptions","organizations_url":"https://api.github.com/users/normanmaurer/orgs","repos_url":"https://api.github.com/users/normanmaurer/repos","events_url":"https://api.github.com/users/normanmaurer/events{/privacy}","received_events_url":"https://api.github.com/users/normanmaurer/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":844994894,"url":"https://api.github.com/repos/apple/swift-nio/labels/patch-version-bump-only","name":"patch-version-bump-only","color":"DE76D2","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/apple/swift-nio/pulls/286/commits","review_comments_url":"https://api.github.com/repos/apple/swift-nio/pulls/286/comments","review_comment_url":"https://api.github.com/repos/apple/swift-nio/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apple/swift-nio/issues/286/comments","statuses_url":"https://api.github.com/repos/apple/swift-nio/statuses/c1bae21ef1f41a188675dafccbd2a040b74e67cf","head":{"label":"weissi:jw-277","ref":"jw-277","sha":"c1bae21ef1f41a188675dafccbd2a040b74e67cf","user":{"login":"weissi","id":624238,"avatar_url":"https://avatars2.githubusercontent.com/u/624238?v=4","gravatar_id":"","url":"https://api.github.com/users/weissi","html_url":"https://github.com/weissi","followers_url":"https://api.github.com/users/weissi/followers","following_url":"https://api.github.com/users/weissi/following{/other_user}","gists_url":"https://api.github.com/users/weissi/gists{/gist_id}","starred_url":"https://api.github.com/users/weissi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weissi/subscriptions","organizations_url":"https://api.github.com/users/weissi/orgs","repos_url":"https://api.github.com/users/weissi/repos","events_url":"https://api.github.com/users/weissi/events{/privacy}","received_events_url":"https://api.github.com/users/weissi/received_events","type":"User","site_admin":false},"repo":{"id":123523477,"name":"swift-nio","full_name":"weissi/swift-nio","owner":{"login":"weissi","id":624238,"avatar_url":"https://avatars2.githubusercontent.com/u/624238?v=4","gravatar_id":"","url":"https://api.github.com/users/weissi","html_url":"https://github.com/weissi","followers_url":"https://api.github.com/users/weissi/followers","following_url":"https://api.github.com/users/weissi/following{/other_user}","gists_url":"https://api.github.com/users/weissi/gists{/gist_id}","starred_url":"https://api.github.com/users/weissi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weissi/subscriptions","organizations_url":"https://api.github.com/users/weissi/orgs","repos_url":"https://api.github.com/users/weissi/repos","events_url":"https://api.github.com/users/weissi/events{/privacy}","received_events_url":"https://api.github.com/users/weissi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/weissi/swift-nio","description":"Event-driven network application framework for high performance protocol servers & clients, non-blocking.","fork":true,"url":"https://api.github.com/repos/weissi/swift-nio","forks_url":"https://api.github.com/repos/weissi/swift-nio/forks","keys_url":"https://api.github.com/repos/weissi/swift-nio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/weissi/swift-nio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/weissi/swift-nio/teams","hooks_url":"https://api.github.com/repos/weissi/swift-nio/hooks","issue_events_url":"https://api.github.com/repos/weissi/swift-nio/issues/events{/number}","events_url":"https://api.github.com/repos/weissi/swift-nio/events","assignees_url":"https://api.github.com/repos/weissi/swift-nio/assignees{/user}","branches_url":"https://api.github.com/repos/weissi/swift-nio/branches{/branch}","tags_url":"https://api.github.com/repos/weissi/swift-nio/tags","blobs_url":"https://api.github.com/repos/weissi/swift-nio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/weissi/swift-nio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/weissi/swift-nio/git/refs{/sha}","trees_url":"https://api.github.com/repos/weissi/swift-nio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/weissi/swift-nio/statuses/{sha}","languages_url":"https://api.github.com/repos/weissi/swift-nio/languages","stargazers_url":"https://api.github.com/repos/weissi/swift-nio/stargazers","contributors_url":"https://api.github.com/repos/weissi/swift-nio/contributors","subscribers_url":"https://api.github.com/repos/weissi/swift-nio/subscribers","subscription_url":"https://api.github.com/repos/weissi/swift-nio/subscription","commits_url":"https://api.github.com/repos/weissi/swift-nio/commits{/sha}","git_commits_url":"https://api.github.com/repos/weissi/swift-nio/git/commits{/sha}","comments_url":"https://api.github.com/repos/weissi/swift-nio/comments{/number}","issue_comment_url":"https://api.github.com/repos/weissi/swift-nio/issues/comments{/number}","contents_url":"https://api.github.com/repos/weissi/swift-nio/contents/{+path}","compare_url":"https://api.github.com/repos/weissi/swift-nio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/weissi/swift-nio/merges","archive_url":"https://api.github.com/repos/weissi/swift-nio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/weissi/swift-nio/downloads","issues_url":"https://api.github.com/repos/weissi/swift-nio/issues{/number}","pulls_url":"https://api.github.com/repos/weissi/swift-nio/pulls{/number}","milestones_url":"https://api.github.com/repos/weissi/swift-nio/milestones{/number}","notifications_url":"https://api.github.com/repos/weissi/swift-nio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/weissi/swift-nio/labels{/name}","releases_url":"https://api.github.com/repos/weissi/swift-nio/releases{/id}","deployments_url":"https://api.github.com/repos/weissi/swift-nio/deployments","created_at":"2018-03-02T03:09:39Z","updated_at":"2018-03-02T03:09:41Z","pushed_at":"2018-04-13T10:31:51Z","git_url":"git://github.com/weissi/swift-nio.git","ssh_url":"git@github.com:weissi/swift-nio.git","clone_url":"https://github.com/weissi/swift-nio.git","svn_url":"https://github.com/weissi/swift-nio","homepage":"","size":3409,"stargazers_count":0,"watchers_count":0,"language":"Swift","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apple:master","ref":"master","sha":"098239bb27bec0a2aa7204ab09335f08d8cd62de","user":{"login":"apple","id":10639145,"avatar_url":"https://avatars0.githubusercontent.com/u/10639145?v=4","gravatar_id":"","url":"https://api.github.com/users/apple","html_url":"https://github.com/apple","followers_url":"https://api.github.com/users/apple/followers","following_url":"https://api.github.com/users/apple/following{/other_user}","gists_url":"https://api.github.com/users/apple/gists{/gist_id}","starred_url":"https://api.github.com/users/apple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apple/subscriptions","organizations_url":"https://api.github.com/users/apple/orgs","repos_url":"https://api.github.com/users/apple/repos","events_url":"https://api.github.com/users/apple/events{/privacy}","received_events_url":"https://api.github.com/users/apple/received_events","type":"Organization","site_admin":false},"repo":{"id":120498971,"name":"swift-nio","full_name":"apple/swift-nio","owner":{"login":"apple","id":10639145,"avatar_url":"https://avatars0.githubusercontent.com/u/10639145?v=4","gravatar_id":"","url":"https://api.github.com/users/apple","html_url":"https://github.com/apple","followers_url":"https://api.github.com/users/apple/followers","following_url":"https://api.github.com/users/apple/following{/other_user}","gists_url":"https://api.github.com/users/apple/gists{/gist_id}","starred_url":"https://api.github.com/users/apple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apple/subscriptions","organizations_url":"https://api.github.com/users/apple/orgs","repos_url":"https://api.github.com/users/apple/repos","events_url":"https://api.github.com/users/apple/events{/privacy}","received_events_url":"https://api.github.com/users/apple/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apple/swift-nio","description":"Event-driven network application framework for high performance protocol servers & clients, non-blocking.","fork":false,"url":"https://api.github.com/repos/apple/swift-nio","forks_url":"https://api.github.com/repos/apple/swift-nio/forks","keys_url":"https://api.github.com/repos/apple/swift-nio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apple/swift-nio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apple/swift-nio/teams","hooks_url":"https://api.github.com/repos/apple/swift-nio/hooks","issue_events_url":"https://api.github.com/repos/apple/swift-nio/issues/events{/number}","events_url":"https://api.github.com/repos/apple/swift-nio/events","assignees_url":"https://api.github.com/repos/apple/swift-nio/assignees{/user}","branches_url":"https://api.github.com/repos/apple/swift-nio/branches{/branch}","tags_url":"https://api.github.com/repos/apple/swift-nio/tags","blobs_url":"https://api.github.com/repos/apple/swift-nio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apple/swift-nio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apple/swift-nio/git/refs{/sha}","trees_url":"https://api.github.com/repos/apple/swift-nio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apple/swift-nio/statuses/{sha}","languages_url":"https://api.github.com/repos/apple/swift-nio/languages","stargazers_url":"https://api.github.com/repos/apple/swift-nio/stargazers","contributors_url":"https://api.github.com/repos/apple/swift-nio/contributors","subscribers_url":"https://api.github.com/repos/apple/swift-nio/subscribers","subscription_url":"https://api.github.com/repos/apple/swift-nio/subscription","commits_url":"https://api.github.com/repos/apple/swift-nio/commits{/sha}","git_commits_url":"https://api.github.com/repos/apple/swift-nio/git/commits{/sha}","comments_url":"https://api.github.com/repos/apple/swift-nio/comments{/number}","issue_comment_url":"https://api.github.com/repos/apple/swift-nio/issues/comments{/number}","contents_url":"https://api.github.com/repos/apple/swift-nio/contents/{+path}","compare_url":"https://api.github.com/repos/apple/swift-nio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apple/swift-nio/merges","archive_url":"https://api.github.com/repos/apple/swift-nio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apple/swift-nio/downloads","issues_url":"https://api.github.com/repos/apple/swift-nio/issues{/number}","pulls_url":"https://api.github.com/repos/apple/swift-nio/pulls{/number}","milestones_url":"https://api.github.com/repos/apple/swift-nio/milestones{/number}","notifications_url":"https://api.github.com/repos/apple/swift-nio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apple/swift-nio/labels{/name}","releases_url":"https://api.github.com/repos/apple/swift-nio/releases{/id}","deployments_url":"https://api.github.com/repos/apple/swift-nio/deployments","created_at":"2018-02-06T17:47:31Z","updated_at":"2018-04-13T10:09:01Z","pushed_at":"2018-04-13T10:31:53Z","git_url":"git://github.com/apple/swift-nio.git","ssh_url":"git@github.com:apple/swift-nio.git","clone_url":"https://github.com/apple/swift-nio.git","svn_url":"https://github.com/apple/swift-nio","homepage":"","size":5530,"stargazers_count":3431,"watchers_count":3431,"language":"Swift","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":134,"mirror_url":null,"archived":false,"open_issues_count":47,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":134,"open_issues":47,"watchers":3431,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apple/swift-nio/pulls/286"},"html":{"href":"https://github.com/apple/swift-nio/pull/286"},"issue":{"href":"https://api.github.com/repos/apple/swift-nio/issues/286"},"comments":{"href":"https://api.github.com/repos/apple/swift-nio/issues/286/comments"},"review_comments":{"href":"https://api.github.com/repos/apple/swift-nio/pulls/286/comments"},"review_comment":{"href":"https://api.github.com/repos/apple/swift-nio/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apple/swift-nio/pulls/286/commits"},"statuses":{"href":"https://api.github.com/repos/apple/swift-nio/statuses/c1bae21ef1f41a188675dafccbd2a040b74e67cf"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"Lukasa"}}