Skip to content

Make C-extension Ractor-safe #10

New issue

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

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

Already on GitHub? # to your account

Open
mohamedhafez opened this issue Sep 19, 2024 · 1 comment
Open

Make C-extension Ractor-safe #10

mohamedhafez opened this issue Sep 19, 2024 · 1 comment

Comments

@mohamedhafez
Copy link

In planning ahead to the near future when TruffleRuby can run C-extensions marked with rb_ext_ractor_safe(true) in parallel, and for when Ractors are no longer just experimental, it would be great if the C-extension could be made Ractor-safe, or marked as such if it already is so! Would be happy to send in a PR in the later case.

@eregon
Copy link
Member

eregon commented Oct 1, 2024

There are some mutable global C variables in the extension:

static const char *syslog_ident = NULL;
static int syslog_options = -1, syslog_facility = -1, syslog_mask = -1;
static int syslog_opened = 0;

These are not thread-safe and most likely not Ractor-safe.
From what I see, the idea is to only allow a single opened Syslog instance at any one time.
That could be made thread-safe by using a mutex around the opening and closing and all these variables.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

No branches or pull requests

2 participants