Download raw body.
rpki-client: add error checks for pthread_* calls
On Fri, Jun 20, 2025 at 04:05:51PM +0200, Theo Buehler wrote:
> On Fri, Jun 20, 2025 at 02:00:07PM +0000, Job Snijders wrote:
> > On Fri, Jun 20, 2025 at 03:51:42PM +0200, Theo Buehler wrote:
> > > Also, we seem to be missing a bunch of pthread_*_destroy() calls.
> >
> > All the mutexes and condition variables are statically initialized
> > (using PTHREAD_MUTEX_INITIALIZER & PTHREAD_COND_INITIALIZER), as I
> > understand it one doesn't need to reset those with pthread_*_destroy().
>
> Well at least in our librthread they allocate the first time they take a
> lock first lock and we release all other resources.
indeed, /usr/src/lib/libc/thread/rthread_mutex.c:_rthread_mutex_timedlock()
also has a helpful comment alongside the _init() call:
/*
* If the mutex is statically initialized, perform the dynamic
* initialization. Note: _thread_mutex_lock() in libc requires
* pthread_mutex_lock() to perform the mutex init when *mutexp
* is NULL.
*/
if (*mutexp == NULL) {
_spinlock(&static_init_lock);
if (*mutexp == NULL)
error = pthread_mutex_init(mutexp, NULL);
_spinunlock(&static_init_lock);
if (error != 0)
return (EINVAL);
}
I concur, pthread_*_destroy() should be used for proper cleanup, even when
statically initialized.
rpki-client: add error checks for pthread_* calls