Re: Extended attributes and thread safety
Christiaan Hofman <[email protected]>
| Newsgroups | gmane.comp.macosx.devel |
|---|---|
| Message-ID | <[email protected]> |
On Aug 31, 2009, at 11:12, Graham Lee wrote: > On Aug 31, 2009, at 10:06 , Christiaan Hofman wrote: > >> >> On Aug 31, 2009, at 8:36, Chris Suter wrote: >> >>> Hi Christian, >>> >>> On Sun, Aug 30, 2009 at 9:48 PM, Christiaan Hofman<[email protected] >>> > wrote: >>>> Does anybody know whether it is safe to use the extended >>>> attribute C-library >>>> at sys/xattr.h (getxattr, setxattr, etc) on background threads? The >>>> documentation does not mention anything about thread safety, but >>>> I could >>>> imagine it to run into problems if it'd use global resources, and >>>> the >>>> functions seem to use at least one global variable. >>> >>> Those functions will be thread safe. It's a bug if they're not. >>> >>> Kind regards, >>> >>> Chris >> >> Thanks Chris. However I am still worried about the fact that they >> access the global variable errno. > > On Mac OS X, errno is a macro wrapping access to a thread-safe > variable: > > extern int * __error(void); > #define errno (*__error()) > > Cheers, > Graham. Good, thanks! However, I do think that still leaves the problem that I don't see why another thread cannot change this same variable / between/ the time that the xattr functions set the variable and my code reads it. In other words, I can't be sure the value I get has anything to do with the error that occurred. Right? Christiaan