Index | Thread | Search

From:
Claudio Jeker <cjeker@diehard.n-r-g.com>
Subject:
Re: rpki-client: cleanup mutexes and conditional variables
To:
Theo Buehler <tb@theobuehler.org>
Cc:
Job Snijders <job@openbsd.org>, tech@openbsd.org
Date:
Tue, 24 Jun 2025 07:41:28 +0200

Download raw body.

Thread
On Tue, Jun 24, 2025 at 07:38:34AM +0200, Theo Buehler wrote:
> On Tue, Jun 24, 2025 at 07:30:27AM +0200, Claudio Jeker wrote:
> > On Mon, Jun 23, 2025 at 11:25:30PM +0000, Job Snijders wrote:
> > > Free the pthreads mutex and conditional variable memory allocations.
> > > Spotted by tb@
> > > 
> > > OK?
> > 
> > All of those use static initalisation. So it is unclear to me if this
> > works on all systems. Documentation is very unclear here.
> 
> POSIX seems explicit enough:
> 
> "The effect shall be equivalent to dynamic initialization by a call to
> pthread_cond_init() with parameter attr specified as NULL."
> 
> Similarly for pthread mutexes.

In that case, OK.
 
> >  
> > > Index: parser.c
> > > ===================================================================
> > > RCS file: /cvs/src/usr.sbin/rpki-client/parser.c,v
> > > diff -u -p -r1.158 parser.c
> > > --- parser.c	23 Jun 2025 22:01:14 -0000	1.158
> > > +++ parser.c	23 Jun 2025 23:21:50 -0000
> > > @@ -1301,6 +1301,15 @@ proc_parser(int fd, int nthreads)
> > >  
> > >  	msgbuf_free(inbufq);
> > >  	ibufq_free(globalmsgq);
> > > +
> > > +	if (pthread_mutex_destroy(&globalq_mtx) != 0)
> > > +		errx(1, "pthread_mutex_destroy");
> > > +	if (pthread_cond_destroy(&globalq_cond) != 0)
> > > +		errx(1, "pthread_cond_destroy");
> > > +	if (pthread_mutex_destroy(&globalmsgq_mtx) != 0)
> > > +		errx(1, "pthread_mutex_destroy");
> > > +	if (pthread_cond_destroy(&globalmsgq_cond) != 0)
> > > +		errx(1, "pthread_cond_destroy");
> > >  
> > >  	if (certid > CERTID_MAX)
> > >  		errx(1, "processing incomplete: too many certificates");
> > > 
> > 
> > -- 
> > :wq Claudio
> > 
> 

-- 
:wq Claudio