|
@@ -1435,20 +1435,22 @@ static const size_t SRFrameHeaderOverhead = 32;
|
|
|
if (aStream.streamError) {
|
|
|
[self _failWithError:aStream.streamError];
|
|
|
} else {
|
|
|
- if (self.readyState != SR_CLOSED) {
|
|
|
- self.readyState = SR_CLOSED;
|
|
|
- _selfRetain = nil;
|
|
|
- }
|
|
|
+ dispatch_async(_workQueue, ^{
|
|
|
+ if (self.readyState != SR_CLOSED) {
|
|
|
+ self.readyState = SR_CLOSED;
|
|
|
+ _selfRetain = nil;
|
|
|
+ }
|
|
|
|
|
|
- if (!_sentClose && !_failed) {
|
|
|
- _sentClose = YES;
|
|
|
- // If we get closed in this state it's probably not clean because we should be sending this when we send messages
|
|
|
- [self _performDelegateBlock:^{
|
|
|
- if ([self.delegate respondsToSelector:@selector(webSocket:didCloseWithCode:reason:wasClean:)]) {
|
|
|
- [self.delegate webSocket:self didCloseWithCode:SRStatusCodeGoingAway reason:@"Stream end encountered" wasClean:NO];
|
|
|
- }
|
|
|
- }];
|
|
|
- }
|
|
|
+ if (!_sentClose && !_failed) {
|
|
|
+ _sentClose = YES;
|
|
|
+ // If we get closed in this state it's probably not clean because we should be sending this when we send messages
|
|
|
+ [self _performDelegateBlock:^{
|
|
|
+ if ([self.delegate respondsToSelector:@selector(webSocket:didCloseWithCode:reason:wasClean:)]) {
|
|
|
+ [self.delegate webSocket:self didCloseWithCode:SRStatusCodeGoingAway reason:@"Stream end encountered" wasClean:NO];
|
|
|
+ }
|
|
|
+ }];
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
break;
|