@@ -461,15 +461,15 @@ cancel_getaddrinfo(void *ptr)
461
461
}
462
462
463
463
static int
464
- do_pthread_create (pthread_t * th , const pthread_attr_t * attr , void * (* start_routine ) (void * ), void * arg )
464
+ do_pthread_create (pthread_t * th , void * (* start_routine ) (void * ), void * arg )
465
465
{
466
466
int limit = 3 , ret ;
467
467
do {
468
468
// It is said that pthread_create may fail spuriously, so we follow the JDK and retry several times.
469
469
//
470
470
// https://bugs.openjdk.org/browse/JDK-8268605
471
471
// https://github.com/openjdk/jdk/commit/e35005d5ce383ddd108096a3079b17cb0bcf76f1
472
- ret = pthread_create (th , attr , start_routine , arg );
472
+ ret = pthread_create (th , 0 , start_routine , arg );
473
473
} while (ret == EAGAIN && limit -- > 0 );
474
474
return ret ;
475
475
}
@@ -489,33 +489,13 @@ rb_getaddrinfo(const char *hostp, const char *portp, const struct addrinfo *hint
489
489
return EAI_MEMORY ;
490
490
}
491
491
492
- pthread_attr_t attr ;
493
- if (pthread_attr_init (& attr ) != 0 ) {
494
- free_getaddrinfo_arg (arg );
495
- return EAI_AGAIN ;
496
- }
497
- #if defined(HAVE_PTHREAD_ATTR_SETAFFINITY_NP ) && defined(HAVE_SCHED_GETCPU )
498
- cpu_set_t tmp_cpu_set ;
499
- CPU_ZERO (& tmp_cpu_set );
500
- int cpu = sched_getcpu ();
501
- if (cpu < CPU_SETSIZE ) {
502
- CPU_SET (cpu , & tmp_cpu_set );
503
- pthread_attr_setaffinity_np (& attr , sizeof (cpu_set_t ), & tmp_cpu_set );
504
- }
505
- #endif
506
-
507
492
pthread_t th ;
508
- if (do_pthread_create (& th , & attr , do_getaddrinfo , arg ) != 0 ) {
493
+ if (do_pthread_create (& th , do_getaddrinfo , arg ) != 0 ) {
509
494
free_getaddrinfo_arg (arg );
510
495
return EAI_AGAIN ;
511
496
}
512
497
pthread_detach (th );
513
498
514
- int r ;
515
- if ((r = pthread_attr_destroy (& attr )) != 0 ) {
516
- rb_bug_errno ("pthread_attr_destroy" , r );
517
- }
518
-
519
499
rb_thread_call_without_gvl2 (wait_getaddrinfo , arg , cancel_getaddrinfo , arg );
520
500
521
501
int need_free = 0 ;
@@ -721,33 +701,13 @@ rb_getnameinfo(const struct sockaddr *sa, socklen_t salen,
721
701
return EAI_MEMORY ;
722
702
}
723
703
724
- pthread_attr_t attr ;
725
- if (pthread_attr_init (& attr ) != 0 ) {
726
- free_getnameinfo_arg (arg );
727
- return EAI_AGAIN ;
728
- }
729
- #if defined(HAVE_PTHREAD_ATTR_SETAFFINITY_NP ) && defined(HAVE_SCHED_GETCPU )
730
- cpu_set_t tmp_cpu_set ;
731
- CPU_ZERO (& tmp_cpu_set );
732
- int cpu = sched_getcpu ();
733
- if (cpu < CPU_SETSIZE ) {
734
- CPU_SET (cpu , & tmp_cpu_set );
735
- pthread_attr_setaffinity_np (& attr , sizeof (cpu_set_t ), & tmp_cpu_set );
736
- }
737
- #endif
738
-
739
704
pthread_t th ;
740
- if (do_pthread_create (& th , & attr , do_getnameinfo , arg ) != 0 ) {
705
+ if (do_pthread_create (& th , do_getnameinfo , arg ) != 0 ) {
741
706
free_getnameinfo_arg (arg );
742
707
return EAI_AGAIN ;
743
708
}
744
709
pthread_detach (th );
745
710
746
- int r ;
747
- if ((r = pthread_attr_destroy (& attr )) != 0 ) {
748
- rb_bug_errno ("pthread_attr_destroy" , r );
749
- }
750
-
751
711
rb_thread_call_without_gvl2 (wait_getnameinfo , arg , cancel_getnameinfo , arg );
752
712
753
713
int need_free = 0 ;
0 commit comments