{"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/PTVS/pulls/comments/124926881","pull_request_review_id":47255890,"id":124926881,"diff_hunk":"@@ -82,80 +82,83 @@ static class DebugConnectionListener {\n         }\n \n         private static void AcceptConnection(IAsyncResult iar) {\n-            Socket socket;\n+            Socket socket = null;\n             var socketSource = ((Socket)iar.AsyncState);\n             try {\n                 socket = socketSource.EndAccept(iar);\n             } catch (SocketException ex) {\n                 Debug.WriteLine(\"DebugConnectionListener socket failed\");\n                 Debug.WriteLine(ex);\n-                return;\n             } catch (ObjectDisposedException) {\n                 Debug.WriteLine(\"DebugConnectionListener socket closed\");\n-                return;\n             }\n \n-            var stream = new NetworkStream(socket, ownsSocket: true);\n-            try {\n-                socket.Blocking = true;\n-\n-                var debugConn = new DebugConnection(stream);\n+            if (socket != null) {\n+                var stream = new NetworkStream(socket, ownsSocket: true);\n                 try {\n-                    string debugId = string.Empty;\n-                    var result = ConnErrorMessages.None;\n-                    using (var connectedEvent = new AutoResetEvent(false)) {\n-                        EventHandler<LDP.LocalConnectedEvent> eventReceived = (object sender, LDP.LocalConnectedEvent ea) => {\n-                            result = (ConnErrorMessages)ea.result;\n-                            debugId = ea.processGuid;\n-                            debugConn.Authenticated();\n+                    socket.Blocking = true;\n+\n+                    var debugConn = new DebugConnection(stream);\n+                    try {\n+                        string debugId = string.Empty;\n+                        var result = ConnErrorMessages.None;\n+                        using (var connectedEvent = new AutoResetEvent(false)) {\n+                            EventHandler<LDP.LocalConnectedEvent> eventReceived = (object sender, LDP.LocalConnectedEvent ea) => {\n+                                result = (ConnErrorMessages)ea.result;\n+                                debugId = ea.processGuid;\n+                                debugConn.Authenticated();\n+                                try {\n+                                    connectedEvent.Set();\n+                                } catch (ObjectDisposedException) {\n+                                }\n+                            };\n+\n+                            debugConn.LegacyLocalConnected += eventReceived;\n                             try {\n-                                connectedEvent.Set();\n-                            } catch (ObjectDisposedException) {\n-                            }\n-                        };\n-\n-                        debugConn.LegacyLocalConnected += eventReceived;\n-                        try {\n-                            debugConn.StartListening();\n-                            bool received = connectedEvent.WaitOne(ConnectTimeoutMs);\n-                            if (!received) {\n-                                throw new TimeoutException();\n+                                debugConn.StartListening();\n+                                bool received = connectedEvent.WaitOne(ConnectTimeoutMs);\n+                                if (!received) {\n+                                    throw new TimeoutException();\n+                                }\n+                            } finally {\n+                                debugConn.LegacyLocalConnected -= eventReceived;\n                             }\n-                        } finally {\n-                            debugConn.LegacyLocalConnected -= eventReceived;\n                         }\n-                    }\n-\n-                    lock (_targets) {\n-                        Guid debugGuid;\n-                        WeakReference weakProcess;\n-                        PythonProcess targetProcess;\n-\n-                        if (Guid.TryParse(debugId, out debugGuid) &&\n-                            _targets.TryGetValue(debugGuid, out weakProcess) &&\n-                            (targetProcess = weakProcess.Target as PythonProcess) != null) {\n \n-                            if (result == ConnErrorMessages.None) {\n-                                targetProcess.Connect(debugConn);\n-                                stream = null;\n-                                socket = null;\n-                                debugConn = null;\n+                        lock (_targets) {\n+                            Guid debugGuid;\n+                            WeakReference weakProcess;\n+                            PythonProcess targetProcess;\n+\n+                            if (Guid.TryParse(debugId, out debugGuid) &&\n+                                _targets.TryGetValue(debugGuid, out weakProcess) &&\n+                                (targetProcess = weakProcess.Target as PythonProcess) != null) {\n+\n+                                if (result == ConnErrorMessages.None) {\n+                                    targetProcess.Connect(debugConn);\n+                                    stream = null;\n+                                    socket = null;\n+                                    debugConn = null;\n+                                } else {\n+                                    WriteErrorToOutputWindow(result, targetProcess);\n+                                    targetProcess.Unregister();\n+                                }\n                             } else {\n-                                WriteErrorToOutputWindow(result, targetProcess);\n-                                targetProcess.Unregister();\n+                                Debug.WriteLine(\"Unknown debug target: {0}\", debugId);\n                             }\n-                        } else {\n-                            Debug.WriteLine(\"Unknown debug target: {0}\", debugId);\n                         }\n+                    } finally {\n+                        debugConn?.Dispose();\n                     }\n+                } catch (IOException) {\n+                } catch (SocketException) {\n+                } catch (TimeoutException) {\n+                } catch (Exception ex) {\n+                    Environment.FailFast(\"DebugConnectionListener.AcceptConnection\", ex);","path":"Python/Product/Debugger/Debugger/DebugConnectionListener.cs","position":123,"original_position":123,"commit_id":"8e27d2b1648dc8397148cabefc5d7c16b5f38709","original_commit_id":"8e27d2b1648dc8397148cabefc5d7c16b5f38709","user":{"login":"zooba","id":1693688,"avatar_url":"https://avatars1.githubusercontent.com/u/1693688?v=3","gravatar_id":"","url":"https://api.github.com/users/zooba","html_url":"https://github.com/zooba","followers_url":"https://api.github.com/users/zooba/followers","following_url":"https://api.github.com/users/zooba/following{/other_user}","gists_url":"https://api.github.com/users/zooba/gists{/gist_id}","starred_url":"https://api.github.com/users/zooba/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zooba/subscriptions","organizations_url":"https://api.github.com/users/zooba/orgs","repos_url":"https://api.github.com/users/zooba/repos","events_url":"https://api.github.com/users/zooba/events{/privacy}","received_events_url":"https://api.github.com/users/zooba/received_events","type":"User","site_admin":false},"body":"Is this better than letting the exception fall out?","created_at":"2017-06-29T22:23:28Z","updated_at":"2017-06-29T22:49:49Z","html_url":"https://github.com/Microsoft/PTVS/pull/2747#discussion_r124926881","pull_request_url":"https://api.github.com/repos/Microsoft/PTVS/pulls/2747","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/PTVS/pulls/comments/124926881"},"html":{"href":"https://github.com/Microsoft/PTVS/pull/2747#discussion_r124926881"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/PTVS/pulls/2747"}}},"pull_request":{"url":"https://api.github.com/repos/Microsoft/PTVS/pulls/2747","id":128244157,"html_url":"https://github.com/Microsoft/PTVS/pull/2747","diff_url":"https://github.com/Microsoft/PTVS/pull/2747.diff","patch_url":"https://github.com/Microsoft/PTVS/pull/2747.patch","issue_url":"https://api.github.com/repos/Microsoft/PTVS/issues/2747","number":2747,"state":"open","locked":false,"title":"Always load Python debugger code as ptvsd package in all scenarios","user":{"login":"int19h","id":1175142,"avatar_url":"https://avatars1.githubusercontent.com/u/1175142?v=3","gravatar_id":"","url":"https://api.github.com/users/int19h","html_url":"https://github.com/int19h","followers_url":"https://api.github.com/users/int19h/followers","following_url":"https://api.github.com/users/int19h/following{/other_user}","gists_url":"https://api.github.com/users/int19h/gists{/gist_id}","starred_url":"https://api.github.com/users/int19h/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/int19h/subscriptions","organizations_url":"https://api.github.com/users/int19h/orgs","repos_url":"https://api.github.com/users/int19h/repos","events_url":"https://api.github.com/users/int19h/events{/privacy}","received_events_url":"https://api.github.com/users/int19h/received_events","type":"User","site_admin":false},"body":"Always load Python debugger code as ptvsd package in all scenarios:\r\n- local launch\r\n- local attach\r\n- remote attach\r\n\r\nFixes of various unrelated product and test issues that came up while testing the change.\r\n\r\nDiagnostic improvements for attach tests - if the test times out, and python.exe is still alive, it'll automatically create a stack minidump.\r\n\r\nNote that this doesn't significantly change the internal structure of the package, or attempt to merge the modules yet. ","created_at":"2017-06-29T20:49:59Z","updated_at":"2017-06-29T22:49:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"982301ac8262870980b568696d5538c9aae38a13","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/Microsoft/PTVS/pulls/2747/commits","review_comments_url":"https://api.github.com/repos/Microsoft/PTVS/pulls/2747/comments","review_comment_url":"https://api.github.com/repos/Microsoft/PTVS/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Microsoft/PTVS/issues/2747/comments","statuses_url":"https://api.github.com/repos/Microsoft/PTVS/statuses/8e27d2b1648dc8397148cabefc5d7c16b5f38709","head":{"label":"int19h:ptvsd3","ref":"ptvsd3","sha":"8e27d2b1648dc8397148cabefc5d7c16b5f38709","user":{"login":"int19h","id":1175142,"avatar_url":"https://avatars1.githubusercontent.com/u/1175142?v=3","gravatar_id":"","url":"https://api.github.com/users/int19h","html_url":"https://github.com/int19h","followers_url":"https://api.github.com/users/int19h/followers","following_url":"https://api.github.com/users/int19h/following{/other_user}","gists_url":"https://api.github.com/users/int19h/gists{/gist_id}","starred_url":"https://api.github.com/users/int19h/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/int19h/subscriptions","organizations_url":"https://api.github.com/users/int19h/orgs","repos_url":"https://api.github.com/users/int19h/repos","events_url":"https://api.github.com/users/int19h/events{/privacy}","received_events_url":"https://api.github.com/users/int19h/received_events","type":"User","site_admin":false},"repo":{"id":34756140,"name":"PTVS","full_name":"int19h/PTVS","owner":{"login":"int19h","id":1175142,"avatar_url":"https://avatars1.githubusercontent.com/u/1175142?v=3","gravatar_id":"","url":"https://api.github.com/users/int19h","html_url":"https://github.com/int19h","followers_url":"https://api.github.com/users/int19h/followers","following_url":"https://api.github.com/users/int19h/following{/other_user}","gists_url":"https://api.github.com/users/int19h/gists{/gist_id}","starred_url":"https://api.github.com/users/int19h/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/int19h/subscriptions","organizations_url":"https://api.github.com/users/int19h/orgs","repos_url":"https://api.github.com/users/int19h/repos","events_url":"https://api.github.com/users/int19h/events{/privacy}","received_events_url":"https://api.github.com/users/int19h/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/int19h/PTVS","description":"Python Tools for Visual Studio","fork":true,"url":"https://api.github.com/repos/int19h/PTVS","forks_url":"https://api.github.com/repos/int19h/PTVS/forks","keys_url":"https://api.github.com/repos/int19h/PTVS/keys{/key_id}","collaborators_url":"https://api.github.com/repos/int19h/PTVS/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/int19h/PTVS/teams","hooks_url":"https://api.github.com/repos/int19h/PTVS/hooks","issue_events_url":"https://api.github.com/repos/int19h/PTVS/issues/events{/number}","events_url":"https://api.github.com/repos/int19h/PTVS/events","assignees_url":"https://api.github.com/repos/int19h/PTVS/assignees{/user}","branches_url":"https://api.github.com/repos/int19h/PTVS/branches{/branch}","tags_url":"https://api.github.com/repos/int19h/PTVS/tags","blobs_url":"https://api.github.com/repos/int19h/PTVS/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/int19h/PTVS/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/int19h/PTVS/git/refs{/sha}","trees_url":"https://api.github.com/repos/int19h/PTVS/git/trees{/sha}","statuses_url":"https://api.github.com/repos/int19h/PTVS/statuses/{sha}","languages_url":"https://api.github.com/repos/int19h/PTVS/languages","stargazers_url":"https://api.github.com/repos/int19h/PTVS/stargazers","contributors_url":"https://api.github.com/repos/int19h/PTVS/contributors","subscribers_url":"https://api.github.com/repos/int19h/PTVS/subscribers","subscription_url":"https://api.github.com/repos/int19h/PTVS/subscription","commits_url":"https://api.github.com/repos/int19h/PTVS/commits{/sha}","git_commits_url":"https://api.github.com/repos/int19h/PTVS/git/commits{/sha}","comments_url":"https://api.github.com/repos/int19h/PTVS/comments{/number}","issue_comment_url":"https://api.github.com/repos/int19h/PTVS/issues/comments{/number}","contents_url":"https://api.github.com/repos/int19h/PTVS/contents/{+path}","compare_url":"https://api.github.com/repos/int19h/PTVS/compare/{base}...{head}","merges_url":"https://api.github.com/repos/int19h/PTVS/merges","archive_url":"https://api.github.com/repos/int19h/PTVS/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/int19h/PTVS/downloads","issues_url":"https://api.github.com/repos/int19h/PTVS/issues{/number}","pulls_url":"https://api.github.com/repos/int19h/PTVS/pulls{/number}","milestones_url":"https://api.github.com/repos/int19h/PTVS/milestones{/number}","notifications_url":"https://api.github.com/repos/int19h/PTVS/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/int19h/PTVS/labels{/name}","releases_url":"https://api.github.com/repos/int19h/PTVS/releases{/id}","deployments_url":"https://api.github.com/repos/int19h/PTVS/deployments","created_at":"2015-04-28T21:11:50Z","updated_at":"2016-02-22T05:50:03Z","pushed_at":"2017-06-29T21:03:57Z","git_url":"git://github.com/int19h/PTVS.git","ssh_url":"git@github.com:int19h/PTVS.git","clone_url":"https://github.com/int19h/PTVS.git","svn_url":"https://github.com/int19h/PTVS","homepage":"https://microsoft.github.io/PTVS","size":165212,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Microsoft:master","ref":"master","sha":"dbb06bed38069b48d01ea0a8f95931ee842c8518","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars1.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":32487763,"name":"PTVS","full_name":"Microsoft/PTVS","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars1.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/PTVS","description":"Python Tools for Visual Studio","fork":false,"url":"https://api.github.com/repos/Microsoft/PTVS","forks_url":"https://api.github.com/repos/Microsoft/PTVS/forks","keys_url":"https://api.github.com/repos/Microsoft/PTVS/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/PTVS/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/PTVS/teams","hooks_url":"https://api.github.com/repos/Microsoft/PTVS/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/PTVS/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/PTVS/events","assignees_url":"https://api.github.com/repos/Microsoft/PTVS/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/PTVS/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/PTVS/tags","blobs_url":"https://api.github.com/repos/Microsoft/PTVS/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/PTVS/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/PTVS/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/PTVS/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/PTVS/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/PTVS/languages","stargazers_url":"https://api.github.com/repos/Microsoft/PTVS/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/PTVS/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/PTVS/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/PTVS/subscription","commits_url":"https://api.github.com/repos/Microsoft/PTVS/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/PTVS/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/PTVS/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/PTVS/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/PTVS/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/PTVS/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/PTVS/merges","archive_url":"https://api.github.com/repos/Microsoft/PTVS/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/PTVS/downloads","issues_url":"https://api.github.com/repos/Microsoft/PTVS/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/PTVS/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/PTVS/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/PTVS/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/PTVS/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/PTVS/releases{/id}","deployments_url":"https://api.github.com/repos/Microsoft/PTVS/deployments","created_at":"2015-03-18T22:30:53Z","updated_at":"2017-06-29T04:53:02Z","pushed_at":"2017-06-29T21:27:48Z","git_url":"git://github.com/Microsoft/PTVS.git","ssh_url":"git@github.com:Microsoft/PTVS.git","clone_url":"https://github.com/Microsoft/PTVS.git","svn_url":"https://github.com/Microsoft/PTVS","homepage":"https://aka.ms/PTVS","size":165137,"stargazers_count":1700,"watchers_count":1700,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":435,"mirror_url":null,"open_issues_count":638,"forks":435,"open_issues":638,"watchers":1700,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/PTVS/pulls/2747"},"html":{"href":"https://github.com/Microsoft/PTVS/pull/2747"},"issue":{"href":"https://api.github.com/repos/Microsoft/PTVS/issues/2747"},"comments":{"href":"https://api.github.com/repos/Microsoft/PTVS/issues/2747/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/PTVS/pulls/2747/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/PTVS/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/PTVS/pulls/2747/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/PTVS/statuses/8e27d2b1648dc8397148cabefc5d7c16b5f38709"}}}}
{"actor":{"display_login":"zooba"}}