[asterisk-dev] Re: strerror() or strerror_r() ?

Tony Mountifield tony at softins.clara.co.uk
Tue Dec 12 02:57:55 MST 2006


In article <200612111258.38222.tilghman at mail.jeffandtilghman.com>,
Tilghman Lesher <tilghman at mail.jeffandtilghman.com> wrote:
> On Monday 11 December 2006 05:15, Tony Mountifield wrote:
> > I was looking up the man page for strerror(), and found that there is
> > an alternative, strerror_r(), which is described as thread-safe,
> > using a buffer passed in from the caller instead of a static buffer.
> >
> > Despite asterisk being heavily multi-threaded, it uses strerror() in
> > many places. Although it's unlikely, I guess there could be a problem
> > if two threads need to report an error simultaneously.
> >
> > Comments?
> 
> Highly unlikely, given that strerror returns a pointer to a table of
> strings on most errors; the only time when it uses the internal static
> buffer is when the error is undefined; in which case, the text message
> would be entirely useless anyway.  This is why we print the numeric of
> the error in most cases afterwards.

Ah, that's reassuring, and makes sense. Thanks!

Tony
-- 
Tony Mountifield
Work: tony at softins.co.uk - http://www.softins.co.uk
Play: tony at mountifield.org - http://tony.mountifield.org


More information about the asterisk-dev mailing list