This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: Understanding why getaddrinfo_a and __gai_enqueue_request use recursive locks
- From: Carlos O'Donell <carlos at redhat dot com>
- To: Will Hawkins <whh8b at virginia dot edu>, libc-help at sourceware dot org
- Cc: Will Hawkins <hawkinsw at gmail dot com>
- Date: Sat, 23 Sep 2017 07:04:45 -0600
- Subject: Re: Understanding why getaddrinfo_a and __gai_enqueue_request use recursive locks
- Authentication-results: sourceware.org; auth=none
- References: <CAE+MWFvvbJT8g=mTAmyC8yi6gdnELgLpagdyFfHHm2rp4a9+ag@mail.gmail.com>
On 09/23/2017 01:08 AM, Will Hawkins wrote:
> 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!
It is a design principle. Acquire the lock if you inspect data that could
be concurrently modified.
You are correct that it looks like the list lock acquisition could be
removed from __gai_enqueue_request. That would be an optimization.
The comments even say so themselves.
Patches welcome! :-)
Please don't be too scared about the contribution checklist, we can
help with any step along the way:
https://sourceware.org/glibc/wiki/Contribution%20checklist
--
Cheers,
Carlos.