Fixing potential deadlock in AFURLConnectionOpeation -setOutputStream: /thanks @aburgel
This commit is contained in:
parent
65af19c524
commit
efb36aaa99
1 changed files with 7 additions and 9 deletions
|
|
@ -321,16 +321,14 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat
|
||||||
|
|
||||||
- (void)setOutputStream:(NSOutputStream *)outputStream {
|
- (void)setOutputStream:(NSOutputStream *)outputStream {
|
||||||
[self.lock lock];
|
[self.lock lock];
|
||||||
if (outputStream == _outputStream) {
|
if (outputStream != _outputStream) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
[self willChangeValueForKey:@"outputStream"];
|
[self willChangeValueForKey:@"outputStream"];
|
||||||
if (_outputStream) {
|
if (_outputStream) {
|
||||||
[_outputStream close];
|
[_outputStream close];
|
||||||
}
|
}
|
||||||
_outputStream = outputStream;
|
_outputStream = outputStream;
|
||||||
[self didChangeValueForKey:@"outputStream"];
|
[self didChangeValueForKey:@"outputStream"];
|
||||||
|
}
|
||||||
[self.lock unlock];
|
[self.lock unlock];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue