-
Notifications
You must be signed in to change notification settings - Fork 133
Do not allow the analyzer to be reset if the server is still initializing #1778
Conversation
@@ -50,6 +50,7 @@ public sealed partial class Server : IDisposable { | |||
private IIndexManager _indexManager; | |||
|
|||
private InitializeParams _initParams; | |||
private bool _initialized; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, this is racy. I can replace it with something else, but I'm not sure how worthwhile it is for a best-effort bool (which is probably atomic already...).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't we default to false?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default boolean is false already.
@@ -249,6 +252,12 @@ public sealed partial class Server : IDisposable { | |||
} | |||
|
|||
private void ResetAnalyzer() { | |||
if (!_initialized) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another approach could be making this to be async method and await until initialized to happen and then proceed. but I saw caller of this thing and how things connected so might be too much work for a corner case.
basically, it looks like this can happen if files in path server watching (such as lib directory and etc) changed before initialization finished. and it those case, ignoring those changes seems fine to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we don't have to go overkill because if it's still being initialized, then any future reads of library files will necessarily be after them being changed, so we'll get the updated info anyway. Reloading is more of a "everything you have before now is wrong, reset", but before init this is meaningless.
(cherry picked from commit c5fb43a)
(cherry picked from commit c5fb43a)
For #1697, #1776.