{"action":"created","comment":{"url":"https://api.github.com/repos/apple/swift-nio/pulls/comments/182429701","pull_request_review_id":113221812,"id":182429701,"diff_hunk":"@@ -297,4 +297,90 @@ public class SocketChannelTest : XCTestCase {\n             XCTFail(\"Unexpected error \\(error)\")\n         }\n     }\n+\n+    public func testPendingConnectNotificationOrder() throws {\n+\n+        class NotificationOrderHandler: ChannelDuplexHandler {\n+            typealias InboundIn = Never\n+            typealias OutboundIn = Never\n+\n+            private var connectPromise: EventLoopPromise<Void>?\n+\n+            public func channelInactive(ctx: ChannelHandlerContext) {\n+                if let connectPromise = self.connectPromise {\n+                    XCTAssertTrue(connectPromise.futureResult.isFulfilled)\n+                } else {\n+                    XCTFail(\"connect(...) not called before\")\n+                }\n+            }\n+\n+            public func connect(ctx: ChannelHandlerContext, to address: SocketAddress, promise: EventLoopPromise<Void>?) {\n+                XCTAssertNil(self.connectPromise)\n+                self.connectPromise = promise\n+                ctx.connect(to: address, promise: promise)\n+            }\n+\n+            func handlerAdded(ctx: ChannelHandlerContext) {\n+                XCTAssertNil(self.connectPromise)\n+            }\n+\n+            func handlerRemoved(ctx: ChannelHandlerContext) {\n+                if let connectPromise = self.connectPromise {\n+                    XCTAssertTrue(connectPromise.futureResult.isFulfilled)\n+                } else {\n+                    XCTFail(\"connect(...) not called before\")\n+                }\n+            }\n+        }\n+\n+        let group = MultiThreadedEventLoopGroup(numThreads: 1)\n+        defer { XCTAssertNoThrow(try group.syncShutdownGracefully()) }\n+\n+        let eventLoop = group.next()\n+        let promise: EventLoopPromise<Void> = eventLoop.newPromise()\n+\n+        class ConnectPendingSocket: Socket {\n+            let promise: EventLoopPromise<Void>\n+            init(promise: EventLoopPromise<Void>) throws {\n+                self.promise = promise\n+                try super.init(protocolFamily: PF_INET, type: Posix.SOCK_STREAM)\n+            }\n+\n+            override func connect(to address: SocketAddress) throws -> Bool {\n+                self.promise.succeed(result: ())\n+                return false\n+            }\n+        }\n+\n+        let channel = try SocketChannel(socket: ConnectPendingSocket(promise: promise), parent: nil, eventLoop: eventLoop as! SelectableEventLoop)\n+\n+        XCTAssertNoThrow(try channel.pipeline.add(handler: NotificationOrderHandler()).then {\n+            channel.register()","path":"Tests/NIOTests/SocketChannelTest.swift","position":62,"original_position":62,"commit_id":"abc35d2281ca88797387a980ebec54fd65cff639","original_commit_id":"abc35d2281ca88797387a980ebec54fd65cff639","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":"You can't do this, it'll cause the channel to be insta-closed because we'll register the channel and then immediately get EPOLLHUP.","created_at":"2018-04-18T13:40:49Z","updated_at":"2018-04-18T13:40:53Z","html_url":"https://github.com/apple/swift-nio/pull/330#discussion_r182429701","pull_request_url":"https://api.github.com/repos/apple/swift-nio/pulls/330","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/apple/swift-nio/pulls/comments/182429701"},"html":{"href":"https://github.com/apple/swift-nio/pull/330#discussion_r182429701"},"pull_request":{"href":"https://api.github.com/repos/apple/swift-nio/pulls/330"}}},"pull_request":{"url":"https://api.github.com/repos/apple/swift-nio/pulls/330","id":182470386,"html_url":"https://github.com/apple/swift-nio/pull/330","diff_url":"https://github.com/apple/swift-nio/pull/330.diff","patch_url":"https://github.com/apple/swift-nio/pull/330.patch","issue_url":"https://api.github.com/repos/apple/swift-nio/issues/330","number":330,"state":"open","locked":false,"title":"Ensure correct ordering of promise notification when connect is still…","user":{"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},"body":"… pending.\r\n\r\nMotivation:\r\n\r\nWhen a pending connect is still in process and the Channel is closed we need to ensure we use the correct ordering when notify the promises and ChannelHandlers in the pipeline.\r\n\r\nThe ordering should be:\r\n\r\n- Notify pending connect promise\r\n- Notify close promise\r\n- Call channelInactive(...)\r\n\r\nModifications:\r\n\r\n- Correct ordering of notification\r\n- Add unit test\r\n\r\nResult:\r\n\r\nEnsure correct ordering when connect is still pending","created_at":"2018-04-18T12:58:34Z","updated_at":"2018-04-18T13:40:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0546dbcbf8fe12b55a808a6a29947f7f666eda21","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/apple/swift-nio/pulls/330/commits","review_comments_url":"https://api.github.com/repos/apple/swift-nio/pulls/330/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/330/comments","statuses_url":"https://api.github.com/repos/apple/swift-nio/statuses/abc35d2281ca88797387a980ebec54fd65cff639","head":{"label":"normanmaurer:pending_connect_promise_notify_order","ref":"pending_connect_promise_notify_order","sha":"abc35d2281ca88797387a980ebec54fd65cff639","user":{"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},"repo":{"id":123526297,"name":"swift-nio","full_name":"normanmaurer/swift-nio","owner":{"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},"private":false,"html_url":"https://github.com/normanmaurer/swift-nio","description":"Event-driven network application framework for high performance protocol servers & clients, non-blocking.","fork":true,"url":"https://api.github.com/repos/normanmaurer/swift-nio","forks_url":"https://api.github.com/repos/normanmaurer/swift-nio/forks","keys_url":"https://api.github.com/repos/normanmaurer/swift-nio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/normanmaurer/swift-nio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/normanmaurer/swift-nio/teams","hooks_url":"https://api.github.com/repos/normanmaurer/swift-nio/hooks","issue_events_url":"https://api.github.com/repos/normanmaurer/swift-nio/issues/events{/number}","events_url":"https://api.github.com/repos/normanmaurer/swift-nio/events","assignees_url":"https://api.github.com/repos/normanmaurer/swift-nio/assignees{/user}","branches_url":"https://api.github.com/repos/normanmaurer/swift-nio/branches{/branch}","tags_url":"https://api.github.com/repos/normanmaurer/swift-nio/tags","blobs_url":"https://api.github.com/repos/normanmaurer/swift-nio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/normanmaurer/swift-nio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/normanmaurer/swift-nio/git/refs{/sha}","trees_url":"https://api.github.com/repos/normanmaurer/swift-nio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/normanmaurer/swift-nio/statuses/{sha}","languages_url":"https://api.github.com/repos/normanmaurer/swift-nio/languages","stargazers_url":"https://api.github.com/repos/normanmaurer/swift-nio/stargazers","contributors_url":"https://api.github.com/repos/normanmaurer/swift-nio/contributors","subscribers_url":"https://api.github.com/repos/normanmaurer/swift-nio/subscribers","subscription_url":"https://api.github.com/repos/normanmaurer/swift-nio/subscription","commits_url":"https://api.github.com/repos/normanmaurer/swift-nio/commits{/sha}","git_commits_url":"https://api.github.com/repos/normanmaurer/swift-nio/git/commits{/sha}","comments_url":"https://api.github.com/repos/normanmaurer/swift-nio/comments{/number}","issue_comment_url":"https://api.github.com/repos/normanmaurer/swift-nio/issues/comments{/number}","contents_url":"https://api.github.com/repos/normanmaurer/swift-nio/contents/{+path}","compare_url":"https://api.github.com/repos/normanmaurer/swift-nio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/normanmaurer/swift-nio/merges","archive_url":"https://api.github.com/repos/normanmaurer/swift-nio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/normanmaurer/swift-nio/downloads","issues_url":"https://api.github.com/repos/normanmaurer/swift-nio/issues{/number}","pulls_url":"https://api.github.com/repos/normanmaurer/swift-nio/pulls{/number}","milestones_url":"https://api.github.com/repos/normanmaurer/swift-nio/milestones{/number}","notifications_url":"https://api.github.com/repos/normanmaurer/swift-nio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/normanmaurer/swift-nio/labels{/name}","releases_url":"https://api.github.com/repos/normanmaurer/swift-nio/releases{/id}","deployments_url":"https://api.github.com/repos/normanmaurer/swift-nio/deployments","created_at":"2018-03-02T03:37:41Z","updated_at":"2018-04-13T06:33:11Z","pushed_at":"2018-04-18T13:30:17Z","git_url":"git://github.com/normanmaurer/swift-nio.git","ssh_url":"git@github.com:normanmaurer/swift-nio.git","clone_url":"https://github.com/normanmaurer/swift-nio.git","svn_url":"https://github.com/normanmaurer/swift-nio","homepage":"","size":3251,"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":"17af3c7c67aad7e5050093c432c1b3774e9d905d","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-18T13:04:29Z","pushed_at":"2018-04-18T13:30:18Z","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":5460,"stargazers_count":3448,"watchers_count":3448,"language":"Swift","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":137,"mirror_url":null,"archived":false,"open_issues_count":54,"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":137,"open_issues":54,"watchers":3448,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apple/swift-nio/pulls/330"},"html":{"href":"https://github.com/apple/swift-nio/pull/330"},"issue":{"href":"https://api.github.com/repos/apple/swift-nio/issues/330"},"comments":{"href":"https://api.github.com/repos/apple/swift-nio/issues/330/comments"},"review_comments":{"href":"https://api.github.com/repos/apple/swift-nio/pulls/330/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/330/commits"},"statuses":{"href":"https://api.github.com/repos/apple/swift-nio/statuses/abc35d2281ca88797387a980ebec54fd65cff639"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"Lukasa"}}