@@ -110,21 +110,25 @@ rb_gvl_event_new(void *callback, rb_event_flag_t event) {
110110 hook -> callback = callback ;
111111 hook -> event = event ;
112112
113- if (pthread_rwlock_wrlock (& rb_gvl_hooks_rw_lock )) {
114- rb_bug ("GVL hooks deadlock" );
113+ int r ;
114+ if ((r = pthread_rwlock_wrlock (& rb_gvl_hooks_rw_lock ))) {
115+ rb_bug_errno ("pthread_rwlock_wrlock" , r );
115116 }
116117
117118 hook -> next = rb_gvl_hooks ;
118119 ATOMIC_PTR_EXCHANGE (rb_gvl_hooks , hook );
119120
120- pthread_rwlock_unlock (& rb_gvl_hooks_rw_lock );
121+ if ((r = pthread_rwlock_unlock (& rb_gvl_hooks_rw_lock ))) {
122+ rb_bug_errno ("pthread_rwlock_unlock" , r );
123+ }
121124 return hook ;
122125}
123126
124127bool
125128rb_gvl_event_delete (gvl_hook_t * hook ) {
126- if (pthread_rwlock_wrlock (& rb_gvl_hooks_rw_lock )) {
127- rb_bug ("GVL hooks deadlock" );
129+ int r ;
130+ if ((r = pthread_rwlock_wrlock (& rb_gvl_hooks_rw_lock ))) {
131+ rb_bug_errno ("pthread_rwlock_wrlock" , r );
128132 }
129133
130134 bool success = FALSE;
@@ -143,7 +147,9 @@ rb_gvl_event_delete(gvl_hook_t * hook) {
143147 } while ((h = h -> next ));
144148 }
145149
146- pthread_rwlock_unlock (& rb_gvl_hooks_rw_lock );
150+ if ((r = pthread_rwlock_unlock (& rb_gvl_hooks_rw_lock ))) {
151+ rb_bug_errno ("pthread_rwlock_unlock" , r );
152+ }
147153
148154 if (success ) {
149155 ruby_xfree (hook );
@@ -153,8 +159,9 @@ rb_gvl_event_delete(gvl_hook_t * hook) {
153159
154160static void
155161rb_gvl_execute_hooks (rb_event_flag_t event , rb_atomic_t waiting ) {
156- if (pthread_rwlock_rdlock (& rb_gvl_hooks_rw_lock )) {
157- rb_bug ("GVL hooks deadlock" );
162+ int r ;
163+ if ((r = pthread_rwlock_rdlock (& rb_gvl_hooks_rw_lock ))) {
164+ rb_bug_errno ("pthread_rwlock_rdlock" , r );
158165 }
159166
160167 if (rb_gvl_hooks ) {
@@ -166,7 +173,9 @@ rb_gvl_execute_hooks(rb_event_flag_t event, rb_atomic_t waiting) {
166173 }
167174 } while ((h = h -> next ));
168175 }
169- pthread_rwlock_unlock (& rb_gvl_hooks_rw_lock );
176+ if ((r = pthread_rwlock_unlock (& rb_gvl_hooks_rw_lock ))) {
177+ rb_bug_errno ("pthread_rwlock_unlock" , r );
178+ }
170179}
171180
172181enum rtimer_state {
@@ -727,11 +736,14 @@ static void native_thread_init(rb_thread_t *th);
727736void
728737Init_native_thread (rb_thread_t * th )
729738{
730- pthread_rwlock_init (& rb_gvl_hooks_rw_lock , NULL );
739+ int r ;
740+ if ((r = pthread_rwlock_init (& rb_gvl_hooks_rw_lock , NULL ))) {
741+ rb_bug_errno ("pthread_rwlock_init" , r );
742+ }
731743
732744#if defined(HAVE_PTHREAD_CONDATTR_SETCLOCK )
733745 if (condattr_monotonic ) {
734- int r = pthread_condattr_init (condattr_monotonic );
746+ r = pthread_condattr_init (condattr_monotonic );
735747 if (r == 0 ) {
736748 r = pthread_condattr_setclock (condattr_monotonic , CLOCK_MONOTONIC );
737749 }
0 commit comments