Re: Extended attributes and thread safety

Graham Lee <[email protected]>
Newsgroups gmane.comp.macosx.devel
Message-ID <[email protected]>
On Aug 31, 2009, at 10:19 , Christiaan Hofman wrote:

>
> On Aug 31, 2009, at 11:12, Graham Lee wrote:
>
>> On Aug 31, 2009, at 10:06 , Christiaan Hofman wrote:
>>
>>>
>>> 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?

Sorry, reading my reply it didn't make the main point clear. Processes  
in Mac OS X have a _per-thread_ error variable which is accessed  
through errno. Will another thread trash your errno? Probably not.  
_Could_ another thread, through malicious design or buggy behaviour,  
trash your errno? Yes. If that's an unacceptable risk to you then the  
two threads need to live in separate processes.

Cheers,
Graham.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.