Re: [PATCH 2/2] hex: make hash_to_hex_algop() and friends thread-safe
- From
Matheus Tavares Bernardino <matheus.bernardino@usp.br>
- Date
- Jun 26, 2020, 00:00 UTC
- Message-ID
- <CAHd-oW4twBf-OskkJoNCxGO22mpWnVvjyiGT+MsJtF6W-J+Gyg@mail.gmail.com>
- In-Reply-To
- <CAHd-oW7GzbtWONYiE9RHQRSzeB1gGvbojJEzdKSMg7qQTMCuOw@mail.gmail.com>
On Thu, Jun 25, 2020 at 8:54 PM Matheus Tavares Bernardino <matheus.bernardino@usp.br> wrote:
Show 22 quoted lines
>
> On Thu, Jun 25, 2020 at 8:08 PM brian m. carlson
> <sandals@crustytoothpaste.net> wrote:
> >
> > On 2020-06-25 at 20:32:57, Matheus Tavares wrote:
> > > +#ifdef HAVE_THREADS
> > > + void *value;
> > > +
> > > + if (pthread_once(&hexbuf_array_once, init_hexbuf_array_key))
> > > + die(_("failed to initialize threads' key for hash to hex conversion"));
> > > +
> > > + value = pthread_key_getspecific(&hexbuf_array_key);
> >
> > I think the portable name for this is "pthread_getspecific". That
> > appears to be what POSIX specifies and what our Windows pthread compat
> > code uses.
>
> Right, thanks for noticing that!
>
> (I wonder how the Windows build passed successfully in our CI [1]...
> Shouldn't the compiler have failed due to a "undefined reference"
> error?)Oh, I know why... I forgot to include "thread-utils.h", so HAVE_THREADS is never defined and this code is always ignored (on both Windows and Linux). That's embarrassing... I'll correct that for v2.