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

Merged
merged 1 commit into from
Mar 13, 2025
Merged

Conversation

fgenesis
Copy link
Contributor

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
@septag septag merged commit a583c84 into septag:master Mar 13, 2025
@septag
Copy link
Owner

septag commented Mar 13, 2025

Thanks!

@mwestphal
Copy link
Contributor

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

FYI I tried to make it atomic but it then refused to compile. I did not investigate more.

@septag
Copy link
Owner

septag commented Mar 15, 2025

I'll try to make all those atomics soon, haven't got the time yet

@septag
Copy link
Owner

septag commented Mar 15, 2025

I removed all volatile vars and now using atomics

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.

3 participants