Replace gethostbyname() with thread-safe getaddrinfo() #104
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
KittenSquad/glewlwyd!104
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "unsafe-gethostbyname"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
get_client_hostname()usesgethostbyname(), which is not thread safe. This is a problem becauseget_client_hostname()gets called from different threads, for example from the OAuth2 module.It looks like this is the reason for the segfault in #101.
This is the stack trace that pointed to the problem:
@ -101,0 +98,4 @@struct addrinfo *lookup;int rv = getaddrinfo(ip_source, NULL, &hints, &lookup);if (rv == 0) {if (lookup->ai_canonname) {Even though it's no longer mandatory, I'm used to declare all variables at the beginning of the functions, I find it easier to read and to miss multiple variables with the same name.
And it does looks like #101 is fixed with this patch, thanks a lot @sth !