diff --git a/ChangeLog b/ChangeLog index 75b26ee..338c853 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,47 @@ +2004-02-17 David Ayers + + * GSWeb.framework/GSWApplication.m + (GSWApplicationMainReal): Reformat. Use GSCurrentThread instead + of objc_thread_id. Remove \n in NSLog type logs. + (GSWApplicationMain): Ditto. + ([GSWApplication init], [GSWApplication lockRequestHandling], + [GSWApplication unlockRequestHandling], [GSWApplication lock], + [GSWApplication unlock], [GSWApplication _sessionClass], + [GSWApplication run], + [GSWApplication addDynCreateClassName:superClassName:], + [GSWApplication pageWithName:], + [GSWApplication dynamicElementWithName:associations:template:]): + Ditto. + * GSWeb.framework/GSWComponent.m + ([GSWComponent appendToResponse:inContext:], [GSWComponent + templateWithHTMLString:declarationString:languages:]): Ditto. + * GSWeb.framework/GSWContext.m + ([GSWContext dealloc], [GSWContext setValidate:]): Ditto. + * GSWeb.framework/GSWDebug.m + (GSWLogC_, GSWLogDumpObjectFn): Ditto. + * GSWeb.framework/GSWDefaultAdaptor.m + ([GSWDefaultAdaptor registerForEvents], + [GSWDefaultAdaptor announceNewConnection:], + [GSWDefaultAdaptor adaptorThreadExited:], + [GSWDefaultAdaptor tryLock]): Ditto. + * GSWeb.framework/GSWDefaultAdaptorThread.m + ([GSWDefaultAdaptorThread setPool:destroyLast:], + [GSWDefaultAdaptorThread run:], + [GSWDefaultAdaptorThread threadExited], + [GSWDefaultAdaptorThread isExpired], + [GSWDefaultAdaptorThread sendRetryLasterResponseToStream:], + [GSWDefaultAdaptorThread + sendConnectionRefusedResponseToStream:withMessage:]): Ditto. + * GSWeb.framework/GSWDeployedBundle.m + ([GSWDeployedBundle initWithPath:], [GSWDeployedBundle dealloc], + [GSWDeployedBundle lock], [GSWDeployedBundle unlock]): Ditto. + * GSWeb.framework/GSWLifebeatThread.m + ([GSWLifebeatThread setPool:destroyLast:], + [GSWLifebeatThread threadExited]): Ditto. + * GSWeb.framework/GSWSession.m + ([GSWSession initWithCoder:], + [GSWSession _releaseAutoreleasePool]): Ditto. + 2004-02-16 David Ayers * GSWeb.framework/GSWUtils.h/m diff --git a/GSWeb.framework/GSWApplication.m b/GSWeb.framework/GSWApplication.m index 74a5056..a68f7dc 100644 --- a/GSWeb.framework/GSWApplication.m +++ b/GSWeb.framework/GSWApplication.m @@ -652,7 +652,8 @@ int GSWApplicationMainReal(NSString* applicationClassName, // Make sure we pass all exceptions back to the requestor. NS_HANDLER { - NSLog(@"Can't create Application (Class:%@)- %@ %@ Name:%@ Reason:%@\n", + NSLog(@"Can't create Application (Class:%@)- " + @"%@ %@ Name:%@ Reason:%@", applicationClass, localException, [localException description], @@ -739,7 +740,8 @@ int GSWApplicationMain(NSString* applicationClassName, ASSIGN(_lastAccessDate,[NSDate date]); [self setTimeOut:0];//No time out - NSDebugMLLog(@"application",@"GSCurrentThreadDictionary()=%@",GSCurrentThreadDictionary()); + NSDebugMLLog(@"application",@"GSCurrentThreadDictionary()=%@", + GSCurrentThreadDictionary()); //Do it before run so application can addTimer,... in -run NSDebugMLLog(@"application",@"[NSRunLoop currentRunLoop]=%@",[NSRunLoop currentRunLoop]); @@ -954,13 +956,15 @@ int GSWApplicationMain(NSString* applicationClassName, LOGObjectFnStart(); if (![self isConcurrentRequestHandlingEnabled]) { - /* NSDebugMLLog(@"application",@"globalLockn=%d globalLock_thread_id=%p objc_thread_id()=%p", + /* NSDebugMLLog(@"application", + @"globalLockn=%d globalLock_thread_id=%@ " + @"GSCurrentThread()=%@", globalLockn,(void*) globalLock_thread_id, - (void*)objc_thread_id()); + GSCurrentThread()); if (globalLockn>0) { - if (globalLock_thread_id!=objc_thread_id()) + if (globalLock_thread_id!=GSCurrentThread()) { NSDebugMLLog(@"application",@"PROBLEM: owner!=thread id"); }; @@ -968,17 +972,18 @@ int GSWApplicationMain(NSString* applicationClassName, */ NS_DURING { - NSDebugLockMLog(@"GLOBALLOCK lock ThreadID=%p\n",(void*)objc_thread_id()); + NSDebugLockMLog(@"GLOBALLOCK lock %@", GSCurrentThread()); LoggedLockBeforeDate(_globalLock,GSW_LOCK_LIMIT); - NSDebugLockMLog(@"GLOBALLOCK locked ThreadID=%p\n",(void*)objc_thread_id()); + NSDebugLockMLog(@"GLOBALLOCK locked %@", GSCurrentThread()); #ifndef NDEBUG _globalLockn++; - _globalLock_thread_id=objc_thread_id(); + _globalLock_thread_id=GSCurrentThread(); #endif - /* NSDebugMLLog(@"application",@"globalLockn=%d globalLock_thread_id=%p objc_thread_id()=%p", - globalLockn, - (void*)globalLock_thread_id, - (void*)objc_thread_id());*/ + /* NSDebugMLLog(@"application", + @"globalLockn=%d globalLock_thread_id=%@ GSCurrentThread()=%@", + globalLockn, + globalLock_thread_id, + GSCurrentThread());*/ } NS_HANDLER { @@ -1002,36 +1007,39 @@ int GSWApplicationMain(NSString* applicationClassName, { NS_DURING { - /* NSDebugMLLog(@"application",@"globalLockn=%d globalLock_thread_id=%p objc_thread_id()=%p", + /* NSDebugMLLog(@"application", + @"globalLockn=%d globalLock_thread_id=%@ GSCurrentThread()=%@", globalLockn, - (void*)globalLock_thread_id, - (void*)objc_thread_id());*/ + globalLock_thread_id, + GSCurrentThread());*/ if (_globalLockn>0) { - if (_globalLock_thread_id!=objc_thread_id()) + if (_globalLock_thread_id!=GSCurrentThread()) { NSDebugMLLog0(@"application",@"PROBLEM: owner!=thread id"); }; }; - NSDebugLockMLog(@"GLOBALLOCK unlock ThreadID=%p\n",(void*)objc_thread_id()); + NSDebugLockMLog(@"GLOBALLOCK unlock %@", GSCurrentThread()); LoggedUnlock(_globalLock); - NSDebugLockMLog(@"GLOBALLOCK unlocked ThreadID=%p\n",(void*)objc_thread_id()); + NSDebugLockMLog(@"GLOBALLOCK unlocked %@",GSCurrentThread()); #ifndef NDEBUG _globalLockn--; if (_globalLockn==0) _globalLock_thread_id=NULL; #endif - /* NSDebugMLLog(@"application",@"globalLockn=%d globalLock_thread_id=%p objc_thread_id()=%p", - globalLockn, - (void*)globalLock_thread_id, - (void*)objc_thread_id());*/ + /* NSDebugMLLog(@"application", + @"globalLockn=%d globalLock_thread_id=%@ GSCurrentThread()=%@", + globalLockn, + globalLock_thread_id, + GSCurrentThread());*/ } NS_HANDLER { - NSDebugMLog(@"globalLockn=%d globalLock_thread_id=%p objc_thread_id()=%p", + NSDebugMLog(@"globalLockn=%d globalLock_thread_id=%@ " + @"GSCurrentThread()=%@", _globalLockn, - (void*)_globalLock_thread_id, - (void*)objc_thread_id()); + _globalLock_thread_id, + GSCurrentThread()); localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException, @"globalLock loggedunlock"); LOGException(@"%@ (%@)",localException,[localException reason]); @@ -1049,13 +1057,14 @@ int GSWApplicationMain(NSString* applicationClassName, //call adaptorsDispatchRequestsConcurrently //OK LOGObjectFnStart(); - /* NSDebugMLLog(@"application",@"selfLockn=%d selfLock_thread_id=%p objc_thread_id()=%p", + /* NSDebugMLLog(@"application",@"selfLockn=%d selfLock_thread_id=%@ " + @"GSCurrentThread()=%@", selfLockn, - (void*)selfLock_thread_id, - (void*)objc_thread_id()); + selfLock_thread_id, + GSCurrentThread()); if (selfLockn>0) { - if (selfLock_thread_id!=objc_thread_id()) + if (selfLock_thread_id!=GSCurrentThread()) { NSDebugMLLog(@"application",@"PROBLEM: owner!=thread id"); }; @@ -1063,22 +1072,23 @@ int GSWApplicationMain(NSString* applicationClassName, */ NS_DURING { - /* printf("SELFLOCK lock ThreadID=%p\n",(void*)objc_thread_id()); - LoggedLockBeforeDate(selfLock,GSW_LOCK_LIMIT); - printf("SELFLOCK locked ThreadID=%p\n",(void*)objc_thread_id()); + /* printf("SELFLOCK lock %@\n", GSCurrentThread()); + LoggedLockBeforeDate(selfLock,GSW_LOCK_LIMIT); + printf("SELFLOCK locked %@\n", GSCurrentThread()); #ifndef NDEBUG - selfLockn++; - selfLock_thread_id=objc_thread_id(); + selfLockn++; + selfLock_thread_id=GSCurrentThread(); #endif -NSDebugMLLog(@"application",@"selfLockn=%d selfLock_thread_id=%p objc_thread_id()=%p", -selfLockn, -(void*)selfLock_thread_id, - (void*)objc_thread_id()); + NSDebugMLLog(@"application", + @"selfLockn=%d selfLock_thread_id=%@ GSCurrentThread()=%@", + selfLockn, + selfLock_thread_id, + GSCurrentThread()); */ [_selfLock lock];//NEW #ifndef NDEBUG _selfLockn++; - _selfLock_thread_id=objc_thread_id(); + _selfLock_thread_id=GSCurrentThread(); #endif } NS_HANDLER @@ -1099,13 +1109,14 @@ selfLockn, //call adaptorsDispatchRequestsConcurrently //OK LOGObjectFnStart(); - /* NSDebugMLLog(@"application",@"selfLockn=%d selfLock_thread_id=%p objc_thread_id()=%p", + /* NSDebugMLLog(@"application", + @"selfLockn=%d selfLock_thread_id=%@ GSCurrentThread()=%@", selfLockn, - (void*)selfLock_thread_id, - (void*)objc_thread_id()); + selfLock_thread_id, + GSCurrentThread()); if (selfLockn>0) { - if (selfLock_thread_id!=objc_thread_id()) + if (selfLock_thread_id!=GSCurrentThread()) { NSDebugMLLog(@"application",@"PROBLEM: owner!=thread id"); }; @@ -1113,27 +1124,29 @@ selfLockn, */ NS_DURING { - NSDebugLockMLog(@"SELFLOCK unlock ThreadID=%p\n",(void*)objc_thread_id()); + NSDebugLockMLog(@"SELFLOCK unlock %@", GSCurrentThread()); // LoggedUnlock(selfLock); [_selfLock unlock];//NEW - NSDebugLockMLog(@"SELFLOCK unlocked ThreadID=%p\n",(void*)objc_thread_id()); + NSDebugLockMLog(@"SELFLOCK unlocked %@", GSCurrentThread()); #ifndef NDEBUG _selfLockn--; if (_selfLockn==0) _selfLock_thread_id=NULL; #endif - /* NSDebugMLLog(@"application",@"selfLockn=%d selfLock_thread_id=%p objc_thread_id()=%p", - selfLockn, - (void*)selfLock_thread_id, - (void*)objc_thread_id()); + /* NSDebugMLLog(@"application",@"selfLockn=%d selfLock_thread_id=%@ " + @"GSCurrentThread()=%@", + selfLockn, + selfLock_thread_id, + GSCurrentThread()); */ } NS_HANDLER { - NSDebugMLLog(@"application",@"selfLockn=%d selfLock_thread_id=%p objc_thread_id()=%p", + NSDebugMLLog(@"application", + @"selfLockn=%d selfLock_thread_id=%@ GSCurrentThread()=%@", _selfLockn, - (void*)_selfLock_thread_id, - (void*)objc_thread_id()); + _selfLock_thread_id, + GSCurrentThread()); localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException, @"selfLock loggedunlock"); LOGException(@"%@ (%@)",localException,[localException reason]); @@ -2572,10 +2585,11 @@ to another instance **/ else { if (!ClassIsKindOfClass(_sessionClass,_gswsessionClass)) - { - //TODO exception - NSDebugMLLog(@"application",@"session class is not a kind of GSWSession\n"); - } + { + //TODO exception + NSDebugMLLog(@"application", + @"session class is not a kind of GSWSession"); + } }; NSDebugMLLog(@"application",@"_sessionClass:%@",_sessionClass); */ @@ -2904,7 +2918,7 @@ to another instance **/ SEL unregisterForEventsSEL=NULL; NSDebugMLLog0(@"application",@"GSWApplication run"); LOGObjectFnStart(); - NSDebugMLog(@"ThreadID=%p\n",(void*)objc_thread_id()); + NSDebugMLog(@"%@", GSCurrentThread()); registerForEventsSEL=@selector(registerForEvents); unregisterForEventsSEL=@selector(unregisterForEvents); NSDebugMLLog(@"application",@"adaptors=%@",_adaptors); @@ -2912,8 +2926,10 @@ to another instance **/ NSDebugMLLog0(@"application",@"NSRunLoop run"); //call adaptor run //call self _openInitialURL - NSDebugMLLog(@"application",@"GSCurrentThreadDictionary()=%@",GSCurrentThreadDictionary()); - NSDebugMLLog(@"application",@"[NSRunLoop currentRunLoop]=%@",[NSRunLoop currentRunLoop]); + NSDebugMLLog(@"application",@"GSCurrentThreadDictionary()=%@", + GSCurrentThreadDictionary()); + NSDebugMLLog(@"application",@"[NSRunLoop currentRunLoop]=%@", + [NSRunLoop currentRunLoop]); NSAssert(_currentRunLoop,@"No runLoop"); NS_DURING @@ -5596,7 +5612,8 @@ to another instance **/ superClassName:(NSString*)superClassName { LOGClassFnStart(); - NSDebugMLLog(@"gswdync",@"ClassName:%@ superClassName:%@\n",className,superClassName); + NSDebugMLLog(@"gswdync",@"ClassName:%@ superClassName:%@", + className, superClassName); [localDynCreateClassNames setObject:superClassName forKey:className]; LOGClassFnStop(); @@ -5699,11 +5716,11 @@ to another instance **/ { GSWComponent* component=nil; Class aClass=nil; - NSDebugMLLog(@"application",@"Page with Name:%@\n",name_); + NSDebugMLLog(@"application",@"Page with Name:%@",name_); //No Name ==> "Main" if (!name_ || [name_ length]==0) name_=GSWMainPageName; - NSDebugMLLog(@"gswcomponents",@"Page with Name:%@\n",name_); + NSDebugMLLog(@"gswcomponents",@"Page with Name:%@",name_); aClass=NSClassFromString(name_); //If not found, search for library if (!aClass) @@ -5726,26 +5743,27 @@ to another instance **/ if (!aClass) { //TODO exception - NSDebugMLLog0(@"application",@"No component class\n"); + NSDebugMLLog0(@"application",@"No component class"); } else { Class GSWComponentClass=[GSWComponent class]); if (!ClassIsKindOfClass(aClass,GSWComponentClass)) - { - NSDebugMLLog0(@"application",@"component class is not a kind of GSWComponent\n"); - //TODO exception - } + { + NSDebugMLLog0(@"application", + @"component class is not a kind of GSWComponent"); + //TODO exception + } else - { - //TODOV - NSDebugMLLog0(@"application",@"Create Componnent\n"); - component=[[aClass new] autorelease]; - if (!component) - { - //TODO exception - }; + { + //TODOV + NSDebugMLLog0(@"application",@"Create Componnent"); + component=[[aClass new] autorelease]; + if (!component) + { + //TODO exception }; + }; }; return component; @@ -5856,38 +5874,42 @@ to another instance **/ //dynamicElementWithName:associations:template: //OldFn -(GSWDynamicElement*)dynamicElementWithName:(NSString*)name_ - associations:(NSDictionary*)someAssociations - template:(GSWElement*)templateElement_ + associations:(NSDictionary*)someAssociations + template:(GSWElement*)templateElement_ { GSWDynamicElement* element=nil; // NSString* elementName=[_XMLElement attributeForKey:@"NAME"]; Class aClass=NSClassFromString(name_); LOGObjectFnNotImplemented(); //TODOFN - NSDebugMLLog0(@"application",@"Begin GSWApplication:dynamicElementWithName\n"); + NSDebugMLLog0(@"application", + @"Begin GSWApplication:dynamicElementWithName"); if (!aClass) + { + ExceptionRaise(@"GSWApplication", + @"GSWApplication: No class named '%@' for " + @"creating dynamic element", + name_); + } + else + { + Class GSWElementClass=[GSWElement class]; + if (!ClassIsKindOfClass(aClass,GSWElementClass)) { ExceptionRaise(@"GSWApplication", - @"GSWApplication: No class named '%@' for creating dynamic element", - name_); + @"GSWApplication: element '%@' is not kind of " + @"GSWElement", + name_); } - else + else { - Class GSWElementClass=[GSWElement class]; - if (!ClassIsKindOfClass(aClass,GSWElementClass)) - { - ExceptionRaise(@"GSWApplication", - @"GSWApplication: element '%@' is not kind of GSWElement", - name_); - } - else - { - NSDebugMLLog(@"application",@"Creating DynamicElement of Class:%@\n",aClass); - element=[[[aClass alloc] initWithName:name_ - associations:someAssociations - template:templateElement_] autorelease]; - NSDebugMLLog(@"application",@"Creating DynamicElement:%@\n",element); - }; + NSDebugMLLog(@"application", + @"Creating DynamicElement of Class:%@",aClass); + element=[[[aClass alloc] initWithName:name_ + associations:someAssociations + template:templateElement_] autorelease]; + NSDebugMLLog(@"application",@"Creating DynamicElement:%@",element); }; + }; return element; }; diff --git a/GSWeb.framework/GSWComponent.m b/GSWeb.framework/GSWComponent.m index e72eec6..b9090de 100644 --- a/GSWeb.framework/GSWComponent.m +++ b/GSWeb.framework/GSWComponent.m @@ -1116,8 +1116,10 @@ associationsKeys:(NSArray*)associationsKeys #ifndef NDEBUG if(GSDebugSet(@"gswcomponents") == YES) - [aResponse appendDebugCommentContentString:[NSString stringWithFormat:@"\n\n", - [self _templateName],[aContext elementID]]];//TODO enlever + [aResponse appendDebugCommentContentString: + [NSString stringWithFormat:@"\n\n", + [self _templateName], + [aContext elementID]]];//TODO enlever #endif GSWAssertIsElementID(aContext); LOGObjectFnStop(); @@ -1925,7 +1927,7 @@ associationsKeys:(NSArray*)associationsKeys languages:(NSArray*)languages { GSWElement* rootElement=nil; - NSDebugMLog0(@"Begin GSWComponent:templateWithHTMLString...\n"); + NSDebugMLog0(@"Begin GSWComponent:templateWithHTMLString..."); rootElement=[GSWTemplateParser templateWithHTMLString:htmlString declarationString:pageDefString languages:languages]; diff --git a/GSWeb.framework/GSWContext.m b/GSWeb.framework/GSWContext.m index 70d8bc1..33aaaa6 100644 --- a/GSWeb.framework/GSWContext.m +++ b/GSWeb.framework/GSWContext.m @@ -57,7 +57,8 @@ static int dontTraceComponentActionURL=0; -(void)dealloc { GSWLogAssertGood(self); - NSDebugFLog(@"Dealloc GSWContext %p. ThreadID=%p",(void*)self,(void*)objc_thread_id()); + NSDebugFLog(@"Dealloc GSWContext %p. %@", + (void*)self, GSCurrentThread()); NSDebugFLog0(@"Release GSWContext senderID"); DESTROY(_senderID); NSDebugFLog0(@"Release GSWContext requestSessionID"); @@ -1476,7 +1477,7 @@ If none, try request languages -(void)setValidate:(BOOL)isValidate { _isValidate = isValidate; - NSDebugMLLog(@"low",@"isValidate=%d\n",(int)isValidate); + NSDebugMLLog(@"low",@"isValidate=%d",(int)isValidate); }; @end diff --git a/GSWeb.framework/GSWDebug.m b/GSWeb.framework/GSWDebug.m index bb41b53..08b96e0 100644 --- a/GSWeb.framework/GSWDebug.m +++ b/GSWeb.framework/GSWDebug.m @@ -61,21 +61,9 @@ NSString* GSWDebugMethodMsg(id obj, SEL sel, const char *file, int line, NSStrin void GSWLogC_(CONST char* file,int line,CONST char* string) { int len=0; -/* if ([NSThread isMultiThreaded]) - { - NSThread* t = [NSThread currentThread]; - fprintf(stderr,"TID="); -#if 0 - if (t && t->_thread_id) - fprintf(stderr,"%p [%ld] (%d) ",(void*)t->_thread_id,(long)t->_thread_id,(int)getpid()); - else -#endif - { -*/ - void* tid=(void*)objc_thread_id(); - fprintf(stderr,"%p [%ld] (%d) ",tid,(long)tid,(int)getpid()); -/* }; - };*/ + const char *thread=[[GSCurrentThread() description] cString]; + + fprintf(stderr,"%s (%d) ", thread, (int)getpid()); fprintf(stderr,"File %s: %d. ",file,line); fprintf(stderr,string); len=strlen(string); @@ -339,8 +327,10 @@ void GSWLogDumpObjectFn(CONST char* file,int line,id object,int deep) Class class = [object class]; if (class) { - NSDebugFLog(@"--%s %d [%d] Dumping object %p of Class %s Description:%@\n", - (file && isalpha(*file) && line>=0 && line<=20000) ? file :"", + NSDebugFLog(@"--%s %d [%d] Dumping object %p of Class %s " + @"Description:%@", + ((file && isalpha(*file) && line>=0 && line<=20000) + ? file : ""), line, deep, (void*)object, diff --git a/GSWeb.framework/GSWDefaultAdaptor.m b/GSWeb.framework/GSWDefaultAdaptor.m index d1cca66..d2d9ffc 100644 --- a/GSWeb.framework/GSWDefaultAdaptor.m +++ b/GSWeb.framework/GSWDefaultAdaptor.m @@ -105,7 +105,8 @@ int allow_severity = LOG_INFO; //-------------------------------------------------------------------- -(void)registerForEvents { - NSDebugDeepMLog(@"START registerForEvents - ThreadID=%p",(void*)objc_thread_id()); + NSDebugDeepMLog(@"START registerForEvents - %@", + GSCurrentThread()); NSAssert(!_fileHandle,@"fileHandle already exists"); NSDebugDeepMLLog(@"info",@"registerForEvents port=%d",_port); NSDebugDeepMLLog(@"info",@"registerForEvents host=%@",_host); @@ -116,7 +117,7 @@ int allow_severity = LOG_INFO; _fileHandle=[[NSFileHandle fileHandleAsServerAtAddress:_host service:[NSString stringWithFormat:@"%d",_port] protocol:@"tcp"] retain]; - NSDebugDeepMLLog(@"info",@"fileHandle=%p\n",(void*)_fileHandle); + NSDebugDeepMLLog(@"info",@"fileHandle=%p",(void*)_fileHandle); [[NSNotificationCenter defaultCenter] addObserver:self selector: @selector(announceNewConnection:) name: NSFileHandleConnectionAcceptedNotification @@ -127,9 +128,11 @@ int allow_severity = LOG_INFO; object:fileHandle]; */ [_fileHandle acceptConnectionInBackgroundAndNotify]; - NSDebugDeepMLog(@"ThreadID=%p - B readInProgress=%d",(void*)objc_thread_id(),(int)[_fileHandle readInProgress]); - [GSWApplication statusLogWithFormat:@"ThreadID %p: Waiting for connections on %@:%d.", - (void*)objc_thread_id(), + NSDebugDeepMLog(@"%@ - B readInProgress=%d", + GSCurrentThread(),(int)[_fileHandle readInProgress]); + [GSWApplication statusLogWithFormat: + @"Thread %@: Waiting for connections on %@:%d.", + GSCurrentThread(), _host, _port]; NSDebugDeepMLog(@"STOP registerForEvents"); @@ -303,20 +306,23 @@ int allow_severity = LOG_INFO; LOGObjectFnStart(); listenHandle=[notification object]; requestDate=[NSCalendarDate calendarDate]; - requestDateString=[NSString stringWithFormat:@"ThreadID=%p: New Request %@",(void*)objc_thread_id(),requestDate]; + requestDateString=[NSString stringWithFormat:@"%@: New Request %@", + GSCurrentThread(),requestDate]; [GSWApplication statusLogWithFormat:@"%@",requestDateString]; NSDebugDeepMLLog(@"info",@"listenHandle=%p",(void*)listenHandle); inStream = [[notification userInfo]objectForKey:@"NSFileHandleNotificationFileHandleItem"]; - NSDebugDeepMLog(@"ThreadID=%p announceNewConnection notification=%@ socketAddress=%@ [notification userInfo]=%p\n", - (void*)objc_thread_id(), + NSDebugDeepMLog(@"%@ announceNewConnection notification=%@ " + @"socketAddress=%@ [notification userInfo]=%p", + GSCurrentThread(), notification, [inStream socketAddress], [notification userInfo]); if (![self isConnectionAllowedWithHandle:inStream returnedMessage:&connRefusedMessage]) { - NSDebugDeepMLog(@"DESTROY the connection: conn refused - ThreadID=%p - A1 readInProgress=%d\n", - (void*)objc_thread_id(), + NSDebugDeepMLog(@"DESTROY the connection: conn refused - " + @"%@ - A1 readInProgress=%d", + GSCurrentThread(), (int)[_fileHandle readInProgress]); [GSWDefaultAdaptorThread sendConnectionRefusedResponseToStream:inStream withMessage:connRefusedMessage]; @@ -324,23 +330,26 @@ int allow_severity = LOG_INFO; } else { - NSDebugDeepMLLog(@"info",@"notification userInfo=%@\n", + NSDebugDeepMLLog(@"info",@"notification userInfo=%@", [notification userInfo]); - NSDebugDeepMLog(@"ThreadID=%p - A1 readInProgress=%d", - (void*)objc_thread_id(), + NSDebugDeepMLog(@"%@ - A1 readInProgress=%d", + GSCurrentThread(), (int)[_fileHandle readInProgress]); - NSDebugDeepMLLog(@"ThreadID=%p - A1 readInProgress=%d\n", - (void*)objc_thread_id(), + NSDebugDeepMLLog(@"%@ - A1 readInProgress=%d", + GSCurrentThread(), (int)[_fileHandle readInProgress]); - NSDebugDeepMLog(@"NEW CONN APP _selfLockn=%d _selfLock_thread_id=%p _globalLockn=%d _globalLock_thread_id=%p threads count=%d waitingThreads count=%d blocked=%d\n", - (int)([GSWApplication application]->_selfLockn), - (void*)([GSWApplication application]->_selfLock_thread_id), - (int)([GSWApplication application]->_globalLockn), - (void*)([GSWApplication application]->_globalLock_thread_id), - [_threads count], - [_waitingThreads count], - _blocked); - NSDebugDeepMLog(@"[waitingThreads count]=%d queueSize=%d",[_waitingThreads count],_queueSize); + NSDebugDeepMLog(@"NEW CONN APP _selfLockn=%d _selfLock_thread_id=%@ " + @"_globalLockn=%d _globalLock_thread_id=%@ " + @"threads count=%d waitingThreads count=%d blocked=%d", + (int)([GSWApplication application]->_selfLockn), + ([GSWApplication application]->_selfLock_thread_id), + (int)([GSWApplication application]->_globalLockn), + ([GSWApplication application]->_globalLock_thread_id), + [_threads count], + [_waitingThreads count], + _blocked); + NSDebugDeepMLog(@"[waitingThreads count]=%d queueSize=%d", + [_waitingThreads count],_queueSize); if ([_waitingThreads count]>=_queueSize) { //remove expired thread @@ -377,8 +386,9 @@ int allow_severity = LOG_INFO; }; if ([_waitingThreads count]>=_queueSize) { - NSDebugDeepMLog(@"DESTROY the connection: too many conn - ThreadID=%p - A1 readInProgress=%d\n", - (void*)objc_thread_id(), + NSDebugDeepMLog(@"DESTROY the connection: too many conn - " + @"%@ - A1 readInProgress=%d", + GSCurrentThread(), (int)[_fileHandle readInProgress]); [GSWDefaultAdaptorThread sendRetryLasterResponseToStream:inStream]; inStream=nil; @@ -409,13 +419,17 @@ int allow_severity = LOG_INFO; if (_isMultiThreadEnabled) { requestDate=[NSCalendarDate calendarDate]; - requestDateString=[NSString stringWithFormat:@"ThreadID=%p : Lauch Thread (Multi) %@", - (void*)objc_thread_id(), - requestDate]; - [GSWApplication statusLogWithFormat:@"%@",requestDateString]; + requestDateString + =[NSString stringWithFormat:@"%@ : " + @"Lauch Thread (Multi) %@", + GSCurrentThread(), + requestDate]; + [GSWApplication statusLogWithFormat:@"%@", + requestDateString]; NSDebugLockMLLog(@"info", - @"ThreadID=%p : Lauch Thread (Multi) %p", - (void*)objc_thread_id(), + @"%@ : " + @"Lauch Thread (Multi) %p", + GSCurrentThread(), (void*)newThread); [NSThread detachNewThreadSelector:@selector(run:) toTarget:newThread @@ -490,16 +504,19 @@ int allow_severity = LOG_INFO; { [listenHandle acceptConnectionInBackgroundAndNotify]; _blocked=NO; - NSDebugDeepMLog(@"ACCEPT ThreadID=%p A2 readInProgress=%d\n", - (void*)objc_thread_id(),(int)[_fileHandle readInProgress]); + NSDebugDeepMLog(@"ACCEPT %@ A2 readInProgress=%d", + GSCurrentThread(), + (int)[_fileHandle readInProgress]); } else { - NSDebugDeepMLog(@"NOT ACCEPT ThreadID=%p A2 readInProgress=%d\n", - (void*)objc_thread_id(),(int)[_fileHandle readInProgress]); + NSDebugDeepMLog(@"NOT ACCEPT %@ A2 readInProgress=%d", + GSCurrentThread(), + (int)[_fileHandle readInProgress]); }; - NSDebugLockMLog(@"ThreadID=%p A2 readInProgress=%d", - (void*)objc_thread_id(),(int)[_fileHandle readInProgress]); + NSDebugLockMLog(@"%@ A2 readInProgress=%d", + GSCurrentThread(), + (int)[_fileHandle readInProgress]); } NS_HANDLER { @@ -516,14 +533,17 @@ int allow_severity = LOG_INFO; [self unlock]; }; NSDebugLockMLLog(@"trace",@"end announceNewConnection"); - NSDebugDeepMLog(@"END NEWCONN APP _selfLockn=%d _selfLock_thread_id=%p _globalLockn=%d _globalLock_thread_id=%p threads count=%d waitingThreads count=%d blocked=%d acceptOK\n", - (int)([GSWApplication application]->_selfLockn), - (void*)([GSWApplication application]->_selfLock_thread_id), - (int)([GSWApplication application]->_globalLockn), - (void*)([GSWApplication application]->_globalLock_thread_id), - [_threads count], - [_waitingThreads count], - _blocked); + NSDebugDeepMLog(@"END NEWCONN APP _selfLockn=%d _selfLock_thread_id=%@ " + @"_globalLockn=%d _globalLock_thread_id=%@ " + @"threads count=%d waitingThreads count=%d " + @"blocked=%d acceptOK", + (int)([GSWApplication application]->_selfLockn), + ([GSWApplication application]->_selfLock_thread_id), + (int)([GSWApplication application]->_globalLockn), + ([GSWApplication application]->_globalLock_thread_id), + [_threads count], + [_waitingThreads count], + _blocked); LOGObjectFnStop(); return self; }; @@ -533,15 +553,17 @@ int allow_severity = LOG_INFO; { LOGObjectFnStart(); // NSDebugMLLog(@"trace",@"adaptorThreadExited"); - NSDebugDeepMLog0(@"adaptorThreadExited\n"); - NSDebugDeepMLog(@"EXIT APP _selfLockn=%d _selfLock_thread_id=%p _globalLockn=%d _globalLock_thread_id=%p threads count=%d waitingThreads count=%d blocked=%d\n", - (int)([GSWApplication application]->_selfLockn), - (void*)([GSWApplication application]->_selfLock_thread_id), - (int)([GSWApplication application]->_globalLockn), - (void*)([GSWApplication application]->_globalLock_thread_id), - [_threads count], - [_waitingThreads count], - _blocked); + NSDebugDeepMLog0(@"adaptorThreadExited"); + NSDebugDeepMLog(@"EXIT APP _selfLockn=%d _selfLock_thread_id=%@ " + @"_globalLockn=%d _globalLock_thread_id=%@ " + @"threads count=%d waitingThreads count=%d blocked=%d", + (int)([GSWApplication application]->_selfLockn), + ([GSWApplication application]->_selfLock_thread_id), + (int)([GSWApplication application]->_globalLockn), + ([GSWApplication application]->_globalLock_thread_id), + [_threads count], + [_waitingThreads count], + _blocked); if ([self tryLock]) { @@ -657,8 +679,9 @@ int allow_severity = LOG_INFO; BOOL accept=[_waitingThreads count]<_queueSize; if (_blocked && accept) { - NSDebugDeepMLog(@"ACCEPT AGAIN ThreadID=%p A2 readInProgress=%d\n", - (void*)objc_thread_id(),(int)[_fileHandle readInProgress]); + NSDebugDeepMLog(@"ACCEPT AGAIN %@ A2 readInProgress=%d", + GSCurrentThread(), + (int)[_fileHandle readInProgress]); [_fileHandle acceptConnectionInBackgroundAndNotify]; _blocked=NO; }; @@ -680,17 +703,19 @@ int allow_severity = LOG_INFO; [self unlock]; }; - NSDebugDeepMLog(@"END EXIT APP _selfLockn=%d _selfLock_thread_id=%p _globalLockn=%d _globalLock_thread_id=%p threads count=%d waitingThreads count=%d blocked=%d\n", - (int)([GSWApplication application]->_selfLockn), - (void*)([GSWApplication application]->_selfLock_thread_id), - (int)([GSWApplication application]->_globalLockn), - (void*)([GSWApplication application]->_globalLock_thread_id), - [_threads count], - [_waitingThreads count], - _blocked); + NSDebugDeepMLog(@"END EXIT APP _selfLockn=%d _selfLock_thread_id=%@ " + @"_globalLockn=%d _globalLock_thread_id=%@ " + @"threads count=%d waitingThreads count=%d blocked=%d", + (int)([GSWApplication application]->_selfLockn), + ([GSWApplication application]->_selfLock_thread_id), + ([GSWApplication application]->_globalLockn), + ([GSWApplication application]->_globalLock_thread_id), + [_threads count], + [_waitingThreads count], + _blocked); // (int)(((UnixFileHandle*)fileHandle)->acceptOK)); - NSDebugLockMLog(@"ThreadID=%p B2 readInProgress=%d", - (void*)objc_thread_id(),(int)[_fileHandle readInProgress]); + NSDebugLockMLog(@"%@ B2 readInProgress=%d", + GSCurrentThread(),(int)[_fileHandle readInProgress]); LOGObjectFnStop(); }; @@ -714,12 +739,12 @@ int allow_severity = LOG_INFO; { BOOL locked=NO; LOGObjectFnStart(); - NSDebugLockMLog(@"self=%p ThreadID=%p TRYLOCK\n", - self,(void*)objc_thread_id()); + NSDebugLockMLog(@"self=%p %@ TRYLOCK", + self, GSCurrentThread()); locked=LoggedTryLockBeforeDate(_selfLock, [NSDate dateWithTimeIntervalSinceNow:90]); - NSDebugLockMLog(@"self=%p ThreadID=%p TRYLOCK LOCKED ?\n", - self,(void*)objc_thread_id()); + NSDebugLockMLog(@"self=%p %@ TRYLOCK LOCKED ?", + self, GSCurrentThread()); LOGObjectFnStop(); return locked; }; @@ -729,11 +754,11 @@ int allow_severity = LOG_INFO; -(void)unlock { LOGObjectFnStart(); - NSDebugLockMLog(@"self=%p ThreadID=%p UNLOCK\n", - self,(void*)objc_thread_id()); + NSDebugLockMLog(@"self=%p %@ UNLOCK", + self, GSCurrentThread()); LoggedUnlock(_selfLock); - NSDebugLockMLog(@"self=%p ThreadID=%p UNLOCK UNLOCKED ?\n", - self,(void*)objc_thread_id()); + NSDebugLockMLog(@"self=%p %@ UNLOCK UNLOCKED ?", + self, GSCurrentThread()); LOGObjectFnStop(); }; diff --git a/GSWeb.framework/GSWDefaultAdaptorThread.m b/GSWeb.framework/GSWDefaultAdaptorThread.m index 05e929e..a75f651 100644 --- a/GSWeb.framework/GSWDefaultAdaptorThread.m +++ b/GSWeb.framework/GSWDefaultAdaptorThread.m @@ -107,10 +107,11 @@ RCS_ID("$Id$") { if (destroy) { - GSWLogMemC("dealloc pool\n"); - GSWLogMemCF("Destroy NSAutoreleasePool: %p. ThreadID=%p",_pool,(void*)objc_thread_id()); + GSWLogMemC("dealloc pool"); + GSWLogMemCF("Destroy NSAutoreleasePool: %p. %@", + _pool, GSCurrentThread()); DESTROY(_pool); - GSWLogMemC("end dealloc pool\n"); + GSWLogMemC("end dealloc pool"); }; _pool=pool; }; @@ -236,8 +237,8 @@ RCS_ID("$Id$") }; }; }; - NSDebugMLog(@"GSWDefaultAdaptorThread: ThreadID=%p run end", - (void*)objc_thread_id()); + NSDebugMLog(@"GSWDefaultAdaptorThread: %@ run end", + GSCurrentThread()); NSDebugMLLog(@"low",@"application:%@", _application); LOGObjectFnStop(); @@ -272,7 +273,7 @@ RCS_ID("$Id$") [self setPool:nil destroyLast:YES]; // LOGObjectFnStop(); - GSWLogDeepC("threadExited\n"); + GSWLogDeepC("threadExited"); }; //-------------------------------------------------------------------- @@ -783,7 +784,7 @@ withAdditionalHeaderLines:(NSArray*)addHeaders -(BOOL)isExpired { BOOL isExpired=(fabs([_creationDate timeIntervalSinceNow])>ADAPTOR_THREAD_TIME_OUT); - NSDebugDeepMLog(@"EXPIRED %@ %f isExpired=%d\n",//connectOK=%d isExpired=%d\n", + NSDebugDeepMLog(@"EXPIRED %@ %f isExpired=%d",//connectOK=%d isExpired=%d", _creationDate, [_creationDate timeIntervalSinceNow], //(int)(((UnixFileHandle*)stream)->connectOK), @@ -808,7 +809,7 @@ withAdditionalHeaderLines:(NSArray*)addHeaders forRequest:nil forceFinalize:YES]; [response setStatus:503];//503=Service Unavailable - NSDebugDeepMLog0(@"sendResponse:\n"); + NSDebugDeepMLog0(@"sendResponse:"); [self sendResponse:response toStream:stream withNamingConv:GSWNAMES_INDEX @@ -832,7 +833,7 @@ withAdditionalHeaderLines:(NSArray*)addHeaders forRequest:nil forceFinalize:YES]; [response setStatus:503];//503=Service Unavailable - NSDebugDeepMLog0(@"sendResponse:\n"); + NSDebugDeepMLog0(@"sendResponse:"); [self sendResponse:response toStream:stream withNamingConv:GSWNAMES_INDEX diff --git a/GSWeb.framework/GSWDeployedBundle.m b/GSWeb.framework/GSWDeployedBundle.m index fb85667..73e0073 100644 --- a/GSWeb.framework/GSWDeployedBundle.m +++ b/GSWeb.framework/GSWDeployedBundle.m @@ -61,7 +61,7 @@ RCS_ID("$Id$") _absolutePathsCache=[NSMutableDictionary new]; _urlsCache=[NSMutableDictionary new]; #ifndef NDEBUG - _creation_thread_id=objc_thread_id(); + _creation_thread_id=GSCurrentThread(); #endif _selfLock=[NSRecursiveLock new]; }; @@ -80,12 +80,13 @@ RCS_ID("$Id$") DESTROY(_absolutePathsCache); DESTROY(_urlsCache); GSWLogC("Dealloc GSWDeployedBundle: selfLock"); - NSDebugFLog(@"selfLock=%p selfLockn=%d selfLock_thread_id=%p objc_thread_id()=%p creation_thread_id=%p", + NSDebugFLog(@"selfLock=%p selfLockn=%d selfLock_thread_id=%@ " + @"GSCurrentThread()=%@ creation_thread_id=%@", (void*)_selfLock, _selfLockn, - (void*)_selfLock_thread_id, - (void*)objc_thread_id(), - (void*)_creation_thread_id); + _selfLock_thread_id, + GSCurrentThread(), + _creation_thread_id); fflush(stderr); DESTROY(_selfLock); GSWLogC("Dealloc GSWDeployedBundle Super"); @@ -644,15 +645,15 @@ if it was not cached **/ { LOGObjectFnStart(); NSDebugMLLog(@"bundles", - @"selfLock=%p selfLockn=%d selfLock_thread_id=%p " - @"objc_thread_id()=%p", + @"selfLock=%p selfLockn=%d selfLock_thread_id=%@ " + @"GSCurrentThread()=%@", (void*)_selfLock, _selfLockn, - (void*)_selfLock_thread_id, - (void*)objc_thread_id()); + _selfLock_thread_id, + GSCurrentThread()); if (_selfLockn>0) { - if (_selfLock_thread_id!=objc_thread_id()) + if (_selfLock_thread_id!=GSCurrentThread()) { NSDebugMLog0(@"PROBLEM: owner!=thread id"); }; @@ -660,15 +661,15 @@ if it was not cached **/ LoggedLockBeforeDate(_selfLock,GSW_LOCK_LIMIT); #ifndef NDEBUG _selfLockn++; - _selfLock_thread_id=objc_thread_id(); + _selfLock_thread_id=GSCurrentThread(); #endif NSDebugMLLog(@"bundles", - @"selfLock=%p selfLockn=%d selfLock_thread_id=%p " - @"objc_thread_id()=%p", + @"selfLock=%p selfLockn=%d selfLock_thread_id=%@ " + @"GSCurrentThread()=%@", _selfLock, _selfLockn, - (void*)_selfLock_thread_id, - (void*)objc_thread_id()); + _selfLock_thread_id, + GSCurrentThread()); LOGObjectFnStop(); }; @@ -677,14 +678,16 @@ if it was not cached **/ -(void)unlock { LOGObjectFnStart(); - NSDebugMLLog(@"bundles",@"selfLock=%p selfLockn=%d selfLock_thread_id=%p objc_thread_id()=%p", + NSDebugMLLog(@"bundles", + @"selfLock=%p selfLockn=%d selfLock_thread_id=%@ " + @"GSCurrentThread()=%@", (void*)_selfLock, _selfLockn, - (void*)_selfLock_thread_id, - (void*)objc_thread_id()); + _selfLock_thread_id, + GSCurrentThread()); if (_selfLockn>0) { - if (_selfLock_thread_id!=objc_thread_id()) + if (_selfLock_thread_id!=GSCurrentThread()) { NSDebugMLog0(@"PROBLEM: owner!=thread id"); }; @@ -695,11 +698,13 @@ if it was not cached **/ if (_selfLockn==0) _selfLock_thread_id=NULL; #endif - NSDebugMLLog(@"bundles",@"selfLock=%p selfLockn=%d selfLock_thread_id=%p objc_thread_id()=%p", + NSDebugMLLog(@"bundles", + @"selfLock=%p selfLockn=%d selfLock_thread_id=%@ " + @"GSCurrentThread()=%@", (void*)_selfLock, _selfLockn, - (void*)_selfLock_thread_id, - (void*)objc_thread_id()); + _selfLock_thread_id, + GSCurrentThread()); LOGObjectFnStop(); }; diff --git a/GSWeb.framework/GSWLifebeatThread.m b/GSWeb.framework/GSWLifebeatThread.m index a13d402..65747ba 100644 --- a/GSWeb.framework/GSWLifebeatThread.m +++ b/GSWeb.framework/GSWLifebeatThread.m @@ -37,6 +37,7 @@ RCS_ID("$Id$") #include #include "GSWeb.h" #include "GSWLifebeatThread.h" +#include //==================================================================== @implementation GSWLifebeatThread @@ -141,10 +142,11 @@ RCS_ID("$Id$") { if (destroy) { - GSWLogMemC("dealloc pool\n"); - GSWLogMemCF("Destroy NSAutoreleasePool: %p. ThreadID=%p",_pool,(void*)objc_thread_id()); + GSWLogMemC("dealloc pool"); + GSWLogMemCF("Destroy NSAutoreleasePool: %p. %@", + _pool, GSCurrentThread()); DESTROY(_pool); - GSWLogMemC("end dealloc pool\n"); + GSWLogMemC("end dealloc pool"); }; _pool=pool; }; @@ -206,7 +208,7 @@ RCS_ID("$Id$") [self setPool:nil destroyLast:YES]; // LOGObjectFnStop(); - GSWLogDeepC("threadExited\n"); + GSWLogDeepC("threadExited"); }; /* //TODO diff --git a/GSWeb.framework/GSWSession.m b/GSWeb.framework/GSWSession.m index 84580a1..dceda1d 100644 --- a/GSWeb.framework/GSWSession.m +++ b/GSWeb.framework/GSWSession.m @@ -238,11 +238,13 @@ RCS_ID("$Id$") -(void)dealloc { GSWLogAssertGood(self); - NSDebugFLog(@"Dealloc GSWSession %p. ThreadID=%p",(void*)self,(void*)objc_thread_id()); + NSDebugFLog(@"Dealloc GSWSession %p. %@", + (void*)self, GSCurrentThread()); NSDebugFLog0(@"Dealloc GSWSession: sessionID"); DESTROY(_sessionID); NSDebugFLog0(@"Dealloc GSWSession:autoreleasePool "); - GSWLogMemCF("Destroy NSAutoreleasePool: %p. ThreadID=%p",_autoreleasePool,(void*)objc_thread_id()); + GSWLogMemCF("Destroy NSAutoreleasePool: %p. %@", + _autoreleasePool, GSCurrentThread()); DESTROY(_autoreleasePool); NSDebugFLog0(@"Dealloc GSWSession: contextArrayStack"); DESTROY(_contextArrayStack); @@ -859,10 +861,10 @@ extern id gcObjectsToBeVisited; fprintf(stderr,"session %p _releaseAutoreleasePool START\n",self); //TODO-NOW remettre [GarbageCollector collectGarbages]; printf("session %p _releaseAutoreleasePool after garbage",self); -fprintf(stderr,"session %p _releaseAutoreleasePool after garbage\n",self); + fprintf(stderr,"session %p _releaseAutoreleasePool after garbage\n",self); DESTROY(_autoreleasePool); printf("session %p _releaseAutoreleasePool STOP\n",self); -fprintf(stderr,"session %p _releaseAutoreleasePool STOP\n",self); + fprintf(stderr,"session %p _releaseAutoreleasePool STOP\n",self); LOGObjectFnStop(); };