{"action":"created","issue":{"url":"https://api.github.com/repos/Valloric/ycmd/issues/310","labels_url":"https://api.github.com/repos/Valloric/ycmd/issues/310/labels{/name}","comments_url":"https://api.github.com/repos/Valloric/ycmd/issues/310/comments","events_url":"https://api.github.com/repos/Valloric/ycmd/issues/310/events","html_url":"https://github.com/Valloric/ycmd/pull/310","id":126974430,"number":310,"title":"[READY] Prevent simultaneous starts of OmniSharp server","user":{"login":"micbou","id":10026824,"avatar_url":"https://avatars.githubusercontent.com/u/10026824?v=3","gravatar_id":"","url":"https://api.github.com/users/micbou","html_url":"https://github.com/micbou","followers_url":"https://api.github.com/users/micbou/followers","following_url":"https://api.github.com/users/micbou/following{/other_user}","gists_url":"https://api.github.com/users/micbou/gists{/gist_id}","starred_url":"https://api.github.com/users/micbou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/micbou/subscriptions","organizations_url":"https://api.github.com/users/micbou/orgs","repos_url":"https://api.github.com/users/micbou/repos","events_url":"https://api.github.com/users/micbou/events{/privacy}","received_events_url":"https://api.github.com/users/micbou/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2016-01-15T22:48:57Z","updated_at":"2016-01-17T02:37:55Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Valloric/ycmd/pulls/310","html_url":"https://github.com/Valloric/ycmd/pull/310","diff_url":"https://github.com/Valloric/ycmd/pull/310.diff","patch_url":"https://github.com/Valloric/ycmd/pull/310.patch"},"body":"Currently, C# completer starts a new server on the `FileReadyToParse` event if no port is defined or the running server does not respond. This can lead to situations where multiple servers with same port and solution are started until one of them become ready. See PR #284 and Valloric/YouCompleteMe#1913. \r\n\r\nThis is fixed by using `ServerIsActive` instead of `ServerIsRunning` to start the server in `OnFileReadyToParse`. We then check `ServerIsRunning` for an early return.\r\n\r\n`ServerIsActive` is updated to check the handle (instead of the port) and to poll the process. We cannot only rely on the port because it can be defined while the process is down: server crashed during start up or its process was directly terminated by the user.\r\n\r\n`ServerIsRunning` and `ServerIsReady` are also changed. We return early in both methods by checking `ServerIsAlive` first and we restrict exceptions catching.\n\n<!-- Reviewable:start -->\n[<img src=\"https://reviewable.io/review_button.png\" height=40 alt=\"Review on Reviewable\"/>](https://reviewable.io/reviews/valloric/ycmd/310)\n<!-- Reviewable:end -->\n"},"comment":{"url":"https://api.github.com/repos/Valloric/ycmd/issues/comments/172285422","html_url":"https://github.com/Valloric/ycmd/pull/310#issuecomment-172285422","issue_url":"https://api.github.com/repos/Valloric/ycmd/issues/310","id":172285422,"user":{"login":"Valloric","id":919444,"avatar_url":"https://avatars.githubusercontent.com/u/919444?v=3","gravatar_id":"","url":"https://api.github.com/users/Valloric","html_url":"https://github.com/Valloric","followers_url":"https://api.github.com/users/Valloric/followers","following_url":"https://api.github.com/users/Valloric/following{/other_user}","gists_url":"https://api.github.com/users/Valloric/gists{/gist_id}","starred_url":"https://api.github.com/users/Valloric/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Valloric/subscriptions","organizations_url":"https://api.github.com/users/Valloric/orgs","repos_url":"https://api.github.com/users/Valloric/repos","events_url":"https://api.github.com/users/Valloric/events{/privacy}","received_events_url":"https://api.github.com/users/Valloric/received_events","type":"User","site_admin":false},"created_at":"2016-01-17T02:37:55Z","updated_at":"2016-01-17T02:37:55Z","body":"\n\n\n\nReview status: all files reviewed at latest revision, 2 unresolved discussions, some commit checks failed.\n\n---\n\n*[ycmd/completers/cs/cs_completer.py, line 585 \\[r3\\]](https://reviewable.io:443/reviews/valloric/ycmd/310#-K8CRGoI1G6NCstXURWM:-K8CRGoI1G6NCstXURWN:-2122545436) ([raw file](https://github.com/valloric/ycmd/blob/c80162089c582248331da91a078ed4acf1fd8537/ycmd/completers/cs/cs_completer.py#L585)):*\n`ServerTerminated` seems to be the exact inverse of `ServerIsActive`, both logically and implementation-wise. Do we need both then? Can we kill one? If we can, let's keep the positive `ServerIsActive`.\n\n---\n\n\n*Comments from the [review on Reviewable.io](https://reviewable.io:443/reviews/valloric/ycmd/310)*\n<!-- Sent from Reviewable.io -->\n"}}