Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Couple fixes for the windows backend #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fgenesis
Copy link

First time dmon user, and it immediately blew up! (When trying to set a watch to a directory that didn't exist. win10.)
So here's a bunch of fixes to make it work more reliably.

Copied from the commit:

  • _dmon.modify_watches is gone. Its use introduced more hazard than gain.
  • Fix possible race conditions when watch creation failed
  • Actually handle errors properly instead of corrupting internal state
  • Don't keep the global mutex held while lazing around in Sleep()
  • Since watches are always deleted in unwatch, there's no use trying to keep a pool of allocated watches around for re-use

I've been thinking to remove the weird "freelist" construct too, if you're ok with that.

Because we can just loop over the (compile-time-bounded) array of active watches and pick the first index that's NULL. Since adding and removing watches is nothing done on a per-frame basis a couple loop iterations don't matter. I'd prefer the gained simplicity.

_dmon.quit should be at least volatile (done now), but an atomic would be even better. Comments?

Lasty, do you mind if i get rid of the #include <stdint.h> for the windows backend? Because I like backwards compatbility with older compilers and this is the single most annoying header to break MSVC <= 2012-ish compatibility.

I'll add some extra commits to the PR when i get the go-ahead from you.

- _dmon.modify_watches is gone. Its use introduced more hazard than gain.
- Fix possible race conditions when watch creation failed
- Actually handle errors properly instead of corrupting internal state
- Don't keep the global mutex held while lazing around in Sleep()
- Since watches are always deleted in unwatch, there's no use trying to
  keep a pool of allocated watches around for re-use
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant