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

windows implementation #4

Closed
blaenk opened this issue Feb 10, 2015 · 16 comments
Closed

windows implementation #4

blaenk opened this issue Feb 10, 2015 · 16 comments

Comments

@blaenk
Copy link
Contributor

blaenk commented Feb 10, 2015

I know you already have this in your todo list, but I thought I would bring it to your attention that someone has provided the signatures for what I believe to be the necessary types and functions here, in case you ever get around to this.

@passcod
Copy link
Member

passcod commented Feb 11, 2015

Useful to know, thanks. I don't have a windows dev box, so this is improbable to happen for a while unless someone wants to work on it.

@blaenk
Copy link
Contributor Author

blaenk commented Apr 25, 2015

cc @retep998

I think if anyone can pull this off it would be him. If he's up for it, perhaps you could answer any questions he might have, @passcod

@retep998
Copy link

retep998 commented Jun 7, 2015

🐰

@retep998
Copy link

retep998 commented Jun 8, 2015

Okay, implementing this is a bit more complex than I thought. I'm getting into a big pile of concurrency, and just handling all the possible error cases is a confusing mire.

@maurizi
Copy link
Contributor

maurizi commented Jun 8, 2015

@retep998 If you don't mind waiting a bit I've got an implementation I've been working on, but I don't think I'll be able to get a PR up until probably this weekend.

@retep998
Copy link

retep998 commented Jun 8, 2015

@maurizi I'll wait for you to create your PR before I make a PR then.

@maurizi
Copy link
Contributor

maurizi commented Jun 14, 2015

An update on this, I have a work-in-progress branch: maurizi@f24f3fe.

I'm still trying to sort out a few issues. I'm trying to pass a completion routine to ReadDirectoryChangesW, but it's never getting called.

@retep998 Any advice on this? Some googling has indicated that using an I/O completion port might be a better plan, but I don't really know.

@retep998
Copy link

@maurizi Completion routines are only called during alertable sleep. Therefore you need to use one of the Ex variants of certain sleeping/waiting methods and specify true for the alertable parameter. However, since you're sleeping you won't be able to listen to the channel at the same time. Thus what I would do is create a semaphore and use WaitForSingleObjectEx on the semaphore. Then every time you push a message to the channel you'd release the semaphore, the thread would wake up, you would read exactly one message, and then go back to waiting.

@blaenk
Copy link
Contributor Author

blaenk commented Jun 15, 2015

@maurizi I don't know if this is of any help to you, but perhaps take a look at how other packages from other languages have tackled this.

As well as general advice on ReadDirectoryChangesW.

Just trying to help! I really want you to succeed with this :)

@jmquigs
Copy link
Contributor

jmquigs commented Nov 17, 2015

Hi folks, I managed to get @maurizi 's branch working.

I used a variant of @retep998 's request and use SleepEx to allow the completion callbacks to fire. I use select! to check a timeout channel on the action loop so that I don't block forever there. With these changes it works for me, but I still need to do some cleanup. Also I'm a bit worried about using select! since the compiler gave me a really scary warning about its instability.

Any other feedback is appreciated, I'm still pretty new at Rust coding.

jmquigs@79b8785

@passcod
Copy link
Member

passcod commented Nov 17, 2015

@jmquigs That's awesome! 💯 When it's ready, do submit a PR, and I'll try to get a Windows box set up so I can compile it.

@jmquigs
Copy link
Contributor

jmquigs commented Nov 17, 2015

@passcod I'm in the process of cleaning it up now. I was trying to get the unit tests working, and noticed that fsevent panics when it can't send a notify event, while inotify and poll appear to ignore that error. What are the required semantics here? Ignore would be better for windows. When the "validate_watch_dir" test exits, the watcher is dropped and it appears that the channel is also closed, but a final event is being processed for file deletion (also from drop), and the send fails for that event.

@passcod
Copy link
Member

passcod commented Nov 18, 2015

Ignore is good :)

@jmquigs
Copy link
Contributor

jmquigs commented Nov 18, 2015

Cool. I also wanted to ask about the single file test:
https://github.com/passcod/rsnotify/blob/master/tests/notify.rs#L81

Its a little funky, in that it appears to create the file before the watcher is watching it. ReadDirectoryChangesW misses it because of that; it only a gets Create event for files created after it is started. To make windows pass, I'd need to modify the test so that it starts the watcher first, and then check something other than create. Or I could create a new test. Do you have a preference?

In general windows has the limitation that the watched path must actually exist, because I need to handle files and directories differently, so I need to know whether its a file/dir up front.

@passcod
Copy link
Member

passcod commented Nov 19, 2015

Create a new test :)

@jmquigs
Copy link
Contributor

jmquigs commented Nov 19, 2015

Ok, I believe I did that in the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants