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

Set the output pipe as a non-block fd and catch EAGAIN when we write into it #28

Merged
merged 3 commits into from
Jun 16, 2024

Conversation

dinosaure
Copy link
Contributor

/cc @haesbaert this is my first try to fix the pipe used to interrupt a domain. WDYT?

lib/miou_unix.ml Outdated Show resolved Hide resolved
Copy link
Contributor

@haesbaert haesbaert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I've added some additional suggestions, I think the non-blocking read is worth having as well, the rest is because haesbaert is a pedantic fanatical :-).

lib/miou_unix.ml Outdated Show resolved Hide resolved
@dinosaure dinosaure merged commit c148cd0 into main Jun 16, 2024
1 check was pending
@dinosaure dinosaure deleted the fix-pipe-interrupt branch June 16, 2024 09:06
@@ -330,10 +330,11 @@ let transmit_fds signals revert tbl fds =
List.fold_left fold signals fds

let interrupted fd fds = List.exists (( = ) fd) fds
let buf = Bytes.create 0x1000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not a great idea, sorry I might I have failed to express myself before.
I'd pre-allocate this per-domain, on whatever structure you have that holds per-domain data.
If you just use a global one, you're basically concurrently writing to the buf from multiple domains, which is not a great idea, it's likely not a a bug per-se because of the current implementation of Bytes where it just copes, but it's an antipattern on the very least.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I was too fast about my last commit, I will fix that and revert as before. Thrme allocation of a small one does not cost too much.

dinosaure added a commit to dinosaure/opam-repository that referenced this pull request Aug 22, 2024
CHANGES:

- Set the internal pipe used to interrupt a domain to a non-blocking mode and
  remove the usage of an atomic which protect how we fill the pipe
  (@haesbaert, @dinosaure, robur-coop/miou#28)
- Expose option to reuse addr/port when we `Miou_unix.bind_and_listen`
  (@ada2k, @dinosaure, robur-coop/miou#27)
- Protect an illegal access to the orphan from a possibly parallel task which
  does not own the orphan value
  (@poytypic, @dinosaure, robur-coop/miou#31, robur-coop/miou#32)
- Be able to pin a specific domain when we want to launch a parallel task
  (@dinosaure, robur-coop/miou#34)
- Expose the `Miou.Backoff` module which can be useful for users
  (@dinosaure, robur-coop/miou#35)
- Fix or improve (from the maintainance point-of-view) the `Miou.Queue` module
  and some internal parts of Miou about the usage of atomics
  (@dinosaure, @polytypic, robur-coop/miou#36, robur-coop/miou#33)
- Prefer to require a `finaliser` function for the `events` value and actually
  close the internal `Unix.pipe` used to interrupt domain than to use
  `Gc.finaliser` and possibly leak file-descriptors
  (spotted by @hannesm, @dinosaure, robur-coop/miou#37)
avsm pushed a commit to avsm/opam-repository that referenced this pull request Sep 5, 2024
CHANGES:

- Set the internal pipe used to interrupt a domain to a non-blocking mode and
  remove the usage of an atomic which protect how we fill the pipe
  (@haesbaert, @dinosaure, robur-coop/miou#28)
- Expose option to reuse addr/port when we `Miou_unix.bind_and_listen`
  (@ada2k, @dinosaure, robur-coop/miou#27)
- Protect an illegal access to the orphan from a possibly parallel task which
  does not own the orphan value
  (@poytypic, @dinosaure, robur-coop/miou#31, robur-coop/miou#32)
- Be able to pin a specific domain when we want to launch a parallel task
  (@dinosaure, robur-coop/miou#34)
- Expose the `Miou.Backoff` module which can be useful for users
  (@dinosaure, robur-coop/miou#35)
- Fix or improve (from the maintainance point-of-view) the `Miou.Queue` module
  and some internal parts of Miou about the usage of atomics
  (@dinosaure, @polytypic, robur-coop/miou#36, robur-coop/miou#33)
- Prefer to require a `finaliser` function for the `events` value and actually
  close the internal `Unix.pipe` used to interrupt domain than to use
  `Gc.finaliser` and possibly leak file-descriptors
  (spotted by @hannesm, @dinosaure, robur-coop/miou#37)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants