aboutsummaryrefslogtreecommitdiffhomepage
path: root/objectivec/GPBUtilities.m
diff options
context:
space:
mode:
authorGravatar Thomas Van Lenten <thomasvl@google.com>2015-12-17 14:35:44 -0500
committerGravatar Thomas Van Lenten <thomasvl@google.com>2015-12-17 16:05:50 -0500
commitd6590d653415c0bfacf97e7f768dd3c994cb8d26 (patch)
tree8c0f6f98eb867d520e95d30d32a6d0e4fe55906c /objectivec/GPBUtilities.m
parentafbc89a263d57bb2e36ce5f07b979c739bb2e8cd (diff)
Drop all use of OSSpinLock
Apple engineers have pointed out that OSSpinLocks are vulnerable to live locking on iOS in cases of priority inversion: . http://mjtsai.com/blog/2015/12/16/osspinlock-is-unsafe/ . https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151214/000372.html - Use a dispatch_semaphore_t within the extension registry. - Use a dispatch_semaphore_t for protecting autocreation within messages. - Drop the custom/internal GPBString class since we don't have really good numbers to judge the locking replacements and it isn't required. We can always bring it back with real data in the future.
Diffstat (limited to 'objectivec/GPBUtilities.m')
-rw-r--r--objectivec/GPBUtilities.m4
1 files changed, 2 insertions, 2 deletions
diff --git a/objectivec/GPBUtilities.m b/objectivec/GPBUtilities.m
index 5ee61230..eaa28bbc 100644
--- a/objectivec/GPBUtilities.m
+++ b/objectivec/GPBUtilities.m
@@ -411,7 +411,7 @@ id GPBGetObjectIvarWithField(GPBMessage *self, GPBFieldDescriptor *field) {
return field.defaultValue.valueMessage;
}
- OSSpinLockLock(&self->readOnlyMutex_);
+ dispatch_semaphore_wait(self->readOnlySemaphore_, DISPATCH_TIME_FOREVER);
GPBMessage *result = GPBGetObjectIvarWithFieldNoAutocreate(self, field);
if (!result) {
// For non repeated messages, create the object, set it and return it.
@@ -420,7 +420,7 @@ id GPBGetObjectIvarWithField(GPBMessage *self, GPBFieldDescriptor *field) {
result = GPBCreateMessageWithAutocreator(field.msgClass, self, field);
GPBSetAutocreatedRetainedObjectIvarWithField(self, field, result);
}
- OSSpinLockUnlock(&self->readOnlyMutex_);
+ dispatch_semaphore_signal(self->readOnlySemaphore_);
return result;
}