public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
* Understanding why getaddrinfo_a and __gai_enqueue_request use recursive locks
@ 2017-09-23  7:08 Will Hawkins
  2017-09-23 13:04 ` Carlos O'Donell
  0 siblings, 1 reply; 17+ messages in thread
From: Will Hawkins @ 2017-09-23  7:08 UTC (permalink / raw)
  To: libc-help; +Cc: Will Hawkins

Hello!

Thank you all for your willingness to be part of the community of
glibc developers and for being so helpful when a novice like me has a
stupid question!

I was looking at the source code for getaddrinfo_a and noticed that it
calls __gai_enqueue_request. The former takes the __gai_requests_mutex
lock at the beginning of its work. The latter does the exact same
thing.

I understand that this will not deadlock because __gai_requests_mutex
is declared as a recursive lock, but I can't see the reason for
locking in both places.

I could imagine that it would be necessary if getaddrinfo_a or
__gai_enqueue_request called itself recursively or both the functions
were publicly accessible but neither of those seems to be the case. It
seems that getaddrinfo_a is the only function that calls
__gai_enqueue_request.

Is this somehow related to the "removal of internal function" change
that Mr. Weimer committed a few months ago (commit ca2085)? In other
words, is this meant to future proof the possibility that someone (a
non-internal user of glibc) calls __gai_enqueue_request directly?

I am sure that there is a very subtle explanation for what is going on
here, but my mind is too simple to get it. I know that the code works,
but I am curious about why.

If you can shed any light on the situation, I'd really appreciate it!

Thanks in advance!

Will

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2017-09-27  6:05 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-23  7:08 Understanding why getaddrinfo_a and __gai_enqueue_request use recursive locks Will Hawkins
2017-09-23 13:04 ` Carlos O'Donell
2017-09-23 14:44   ` Will Hawkins
2017-09-25 16:13     ` Carlos O'Donell
2017-09-25 17:05       ` Will Hawkins
2017-09-25 17:23       ` Hal Murray
2017-09-25 19:06         ` Carlos O'Donell
2017-09-25 20:38           ` Florian Weimer
2017-09-25 20:39         ` Florian Weimer
2017-09-26  6:29           ` Hal Murray
2017-09-25 23:00       ` Will Hawkins
2017-09-26  4:42         ` Carlos O'Donell
2017-09-26  6:06           ` Will Hawkins
2017-09-26 18:39             ` Will Hawkins
2017-09-27  5:54               ` Carlos O'Donell
2017-09-27  6:02                 ` Will Hawkins
2017-09-27  6:05                   ` Carlos O'Donell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).