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

Tilghman Lesher tilghman at mail.jeffandtilghman.com
Mon Dec 11 11:58:37 MST 2006


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.

-- 
Tilghman


More information about the asterisk-dev mailing list