-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Fix of not picking file modifications. #12353
Conversation
Inapproriate use of win api in fs_even_node module. In fsevents_win.cpp there are a thread that monitors file system events queue and post messages to uv library. Proposed solution is to use extra bool variable in THREADINFO structure to control thread exit state
@@ -1,5 +1,5 @@ | |||
/* | |||
* Copyright (c) 2014 - present Adobe Systems Incorporated. All rights reserved. |
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.
This change, the base of your commit, seems to be a left-over of the intermediate work. Could you please rebase the commit on top of adobe/master
?
EDIT: this is an incorrect comment, my bad.
@peterflynn, @bchintx, @abose: we were able to reproduce the filewatchers going offline. we expect this is supposed to fix #7638 and related issues. The issue occurs when some other tools interferes with the same file(s) causing "spurious" messages which result in this condition resolves to The fix consists of keeping an internal flag of whether the filewatchers should quit instead of relying on specific parameters of the "terminate" message. |
@@ -337,7 +339,7 @@ DWORD WINAPI NodeFSEvents::Run(LPVOID lpData) | |||
{ | |||
// iterate watching for directory changes until we're signalled to stop | |||
BOOL bContinue = TRUE; |
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.
This variable should be taken off entirely. Since you removed the code at lines 386-390, bContinue
never changes the value and having it around is excessive and not needed.
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.
According to changes now bContinue reflects status from winapi call at line 346 ReadDirectoryChangesW, in some situations that function may fail and return false according to MSDN, that leads to looper exit. Do you propose to skip error handling for that function and continue watching thread as well?
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.
Nevermind, I simply missed that line. You're right, the logic's good.
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.
@mfatekho I think there's still a logic error here. If the ReadDirectoryChangesW()
call below fails, then bContinue
is assigned the value of FALSE
. As a result, on the next iteration of the loop, the while
condition below in line 342 will still be false, and we'll still get kicked out of the loop.
I'd partially agree with @busykai 's comment above, and propose removing bContinue
from the while
loop condition expression in line 342. In fact, you might as well get rid of bContinue
variable altogether and just move the ReadDirectoryChangesW()
call inside the if
condition in line 351.
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.
Hi @bchintx there are several points with removing bContinue
and leaving the rest untouched.
- on line 247 there are
FILE_FLAG_OVERLAPPED
is set meaningReadDirectoryChangesSW
is working in async mode. - MSDN says that for asynchronous mode returning value is a result of task submission, false means we run out of some resources, handles, stack, ram, etc.
- Submitting new requests, e.g. calling
ReadDirectoryChangesSW
in that situation (if that ever happen i believe in low resource condition there will be lots of problems) makes situation even worse: I'm not sure whether that function will issueSwitchToThread
call, if not we will have one cpu core load spot until low resource condition go away. - Further reading of possible error codes reported by
ReadDirectoryChangesW()
makes me think they all are not recoverable, so no point to keep that loop
I just wanted to say that if we simply ignore that error we have to think about possible short loop that burns CPU, and at least add SwitchToThread()
, Sleep(0)
, etc, if we decided to not abort watcher thread.
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.
LGTM. Will merge soon after the copyright is fixed. |
LGTM 👍 |
This looks good to me. Totally got PTSD from old C++ days... :D |
Looks like a simple fix to get rid of the problem. |
Please don't merge quite yet. Please see my comment inline above, as I think there's still a logic error that will prevent the fix from working as expected. |
@bchintx I was thinking about getting rid of |
Hi guys, |
{ | ||
&dwBytesReturned, lpThreadInfo->m_lpOverlapped, NULL)) { | ||
break; | ||
} | ||
// wait for a signal |
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.
Lines 351-358 can be indented left now.
Poking @bchintx to have another look. |
Looks good to me. Merging! Nice work @mfatekho! |
Just trying out brackets for the first time today. Here's my trouble scenario: In the Geany editor under Edit->Preferences->Files-> Disc check timeout, you can set how often the disk is checked and it will prompt you to reload the file if changes are detected Is there something like that for Brackets? |
Inapproriate use of win api in fs_even_node module. In fsevents_win.cpp there are a thread that monitors file system events queue and post messages to uv library. Proposed solution is to use extra bool variable in THREADINFO structure to control thread exit state
@busykai