瀏覽代碼

Check for main thread only during first +initialize call

Pierre-Olivier Latour 11 年之前
父節點
當前提交
5dee044caa
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      CGDWebServer/GCDWebServerConnection.m

+ 1 - 1
CGDWebServer/GCDWebServerConnection.m

@@ -244,7 +244,6 @@ static dispatch_queue_t _formatterQueue = NULL;
 @synthesize server=_server, address=_address, totalBytesRead=_bytesRead, totalBytesWritten=_bytesWritten;
 
 + (void)initialize {
-  DCHECK([NSThread isMainThread]);  // NSDateFormatter should be initialized on main thread
   if (_separatorData == nil) {
     _separatorData = [[NSData alloc] initWithBytes:"\r\n\r\n" length:4];
     DCHECK(_separatorData);
@@ -260,6 +259,7 @@ static dispatch_queue_t _formatterQueue = NULL;
     DCHECK(_continueData);
   }
   if (_dateFormatter == nil) {
+    DCHECK([NSThread isMainThread]);  // NSDateFormatter should be initialized on main thread
     _dateFormatter = [[NSDateFormatter alloc] init];
     _dateFormatter.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"GMT"];
     _dateFormatter.dateFormat = @"EEE',' dd MMM yyyy HH':'mm':'ss 'GMT'";