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

[wip] Allow callbacks to be registered for GVL related events #119

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Hard crash on pthread_rwlock errors
  • Loading branch information
byroot committed Jan 27, 2022
commit b867e19f05b3660a215c82a8c55ce2491a8f7512
10 changes: 3 additions & 7 deletions thread_pthread.c
Original file line number Diff line number Diff line change
@@ -111,9 +111,7 @@ rb_gvl_event_new(void *callback, rb_event_flag_t event) {
hook->event = event;

if (pthread_rwlock_wrlock(&rb_gvl_hooks_rw_lock)) {
// TODO: better way to deal with error?
ruby_xfree(hook);
return NULL;
rb_bug("GVL hooks deadlock");
}

hook->next = rb_gvl_hooks;
@@ -126,8 +124,7 @@ rb_gvl_event_new(void *callback, rb_event_flag_t event) {
bool
rb_gvl_event_delete(gvl_hook_t * hook) {
if (pthread_rwlock_wrlock(&rb_gvl_hooks_rw_lock)) {
// TODO: better way to deal with error?
return FALSE;
rb_bug("GVL hooks deadlock");
}

bool success = FALSE;
@@ -157,8 +154,7 @@ rb_gvl_event_delete(gvl_hook_t * hook) {
void
rb_gvl_execute_hooks(rb_event_flag_t event, rb_atomic_t waiting) {
if (pthread_rwlock_rdlock(&rb_gvl_hooks_rw_lock)) {
// TODO: better way to deal with error?
return;
rb_bug("GVL hooks deadlock");
}

if (rb_gvl_hooks) {