Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Free pthread_attr after setting up the thread
[bug #20149]
  • Loading branch information
HParker authored and djensenius committed Jan 31, 2024
commit dff080dc4159328c17ef21123b20a5f428b8e404
12 changes: 11 additions & 1 deletion ext/socket/raddrinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,11 @@ rb_getaddrinfo(const char *hostp, const char *portp, const struct addrinfo *hint
}
pthread_detach(th);

int r;
if ((r = pthread_attr_destroy(&attr)) != 0) {
rb_bug_errno("pthread_attr_destroy", r);
}

rb_thread_call_without_gvl2(wait_getaddrinfo, arg, cancel_getaddrinfo, arg);

int need_free = 0;
Expand Down Expand Up @@ -732,12 +737,17 @@ rb_getnameinfo(const struct sockaddr *sa, socklen_t salen,
#endif

pthread_t th;
if (do_pthread_create(&th, 0, do_getnameinfo, arg) != 0) {
if (do_pthread_create(&th, &attr, do_getnameinfo, arg) != 0) {
free_getnameinfo_arg(arg);
return EAI_AGAIN;
}
pthread_detach(th);

int r;
if ((r = pthread_attr_destroy(&attr)) != 0) {
rb_bug_errno("pthread_attr_destroy", r);
}

rb_thread_call_without_gvl2(wait_getnameinfo, arg, cancel_getnameinfo, arg);

int need_free = 0;
Expand Down