kozlek/HWSensors — pull request #31 by RehabMan (2012-12-24 17:10:50+00:00)
Title: Use mutex lock instead of copies for SystemUIServer crash

I saw the problem with multithreaded access to HWMonitorEngine data, and implemented a different fix. Actually, I think there still may be a problem with your fix.

Making copies of the array in this case may decrease the likelihood of having multithreaded access to the data because the copy will happen faster, but it will probably still happen (if you think about it, NSArray:withArray has to enumerate the array to copy it, so if it is modified while being copied, there is still a problem). Apple's docs clearly state that these classes are not thread safe, so really should be using a mutex to protect access to them.

I have implemented a fix using NSRecursiveLock. In addition, I was able to eliminate the code making copies of the array. Check it out in commit 435ac5b.

Note: I'm not sure how this pull request thing is supposed to work. I would have thought I could make a pull request for just the single commit, but it does not appear that way.