瀏覽代碼

Making pumping data non-reenatrant

This was causing an issue with testcase 9.3.2 getting a stack overflow.
Mike Lewis 13 年之前
父節點
當前提交
4393f8f5e2
共有 1 個文件被更改,包括 10 次插入0 次删除
  1. 10 0
      SocketRocket/SRWebSocket.m

+ 10 - 0
SocketRocket/SRWebSocket.m

@@ -239,6 +239,8 @@ typedef void (^data_callback)(SRWebSocket *webSocket,  NSData *data);
     BOOL _didFail;
     int _closeCode;
     
+    BOOL _isPumping;
+    
     // We use this to retain ourselves.
     __strong SRWebSocket *_selfRetain;
     
@@ -1168,9 +1170,17 @@ static const char CRLFCRLFBytes[] = {'\r', '\n', '\r', '\n'};
 {
     assert(dispatch_get_current_queue() == _workQueue);
     
+    if (!_isPumping) {
+        _isPumping = YES;
+    } else {
+        return;
+    }
+    
     while ([self _innerPumpScanner]) {
         
     }
+    
+    _isPumping = NO;
 }
 
 //#define NOMASK