2002-03-06 23:13:23 +00:00
|
|
|
/** GSWDefaultAdaptor.m - <title>GSWeb: Class GSWDefaultAdaptor</title>
|
|
|
|
Copyright (C) 1999-2002 Free Software Foundation, Inc.
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2002-03-06 23:13:23 +00:00
|
|
|
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
|
2000-01-22 12:49:49 +00:00
|
|
|
Date: Jan 1999
|
2002-03-06 23:13:23 +00:00
|
|
|
|
|
|
|
$Revision$
|
|
|
|
$Date$
|
|
|
|
|
|
|
|
<abstract></abstract>
|
|
|
|
|
2000-01-22 12:49:49 +00:00
|
|
|
This file is part of the GNUstep Web Library.
|
2002-03-06 23:13:23 +00:00
|
|
|
|
|
|
|
<license>
|
2000-01-22 12:49:49 +00:00
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
|
|
|
License along with this library; if not, write to the Free
|
|
|
|
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
2002-03-06 23:13:23 +00:00
|
|
|
</license>
|
|
|
|
**/
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
static char rcsId[] = "$Id$";
|
|
|
|
|
2000-10-30 15:36:50 +00:00
|
|
|
#include <GSWeb/GSWeb.h>
|
2002-03-06 23:13:23 +00:00
|
|
|
#include <gnustep/base/UnixFileHandle.h>
|
|
|
|
#if HAVE_LIBWRAP
|
|
|
|
#include <tcpd.h>
|
|
|
|
#include <syslog.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAVE_LIBWRAP
|
|
|
|
int deny_severity = LOG_WARNING;
|
|
|
|
int allow_severity = LOG_INFO;
|
|
|
|
/*static*/ void twist_option(char *value,struct request_info *request)
|
|
|
|
{
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
@implementation GSWDefaultAdaptor
|
|
|
|
|
2002-03-06 23:13:23 +00:00
|
|
|
-(id)initWithName:(NSString*)name
|
|
|
|
arguments:(NSDictionary*)arguments
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2001-03-11 Manuel Guesdon <mguesdon@orange-concept.com>
* GSWeb.framework/GSWWOCompatibility.h/.m: added
* GSWeb.framework/GNUmakefile: added GSWWOCompatibility.h/.m
* GSWeb.framework/GSWApplication.h/m: added WOApplicationMain, handle WO/GSWeb names
* GSWeb.framework/GSWContext.m: handle WO/GSWeb names, added traces
* GSWeb.framework/GSWConstants.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWDynamicURLString.m: handle WO/GSWeb names
* GSWeb.framework/GSWProjectBundle.m/.h: handle WO/GSWeb names, suppress warnings
* GSWeb.framework/GSWSession.m: handle WO/GSWeb names
* GSWeb.framework/GSWRequest.m: handle WO/GSWeb names
* GSWeb.framework/GSWTemplateParser.m: handle WO/GSWeb names,
added tag counts to help errors hunt
* GSWeb.framework/GSWBundle.m: handle WO/GSWeb names, added traces
* GSWeb.framework/GSWResourceManager.m: handle WO/GSWeb names
* GSWeb.framework/GSWURLValuedElementData.m: handle WO/GSWeb names
* GSWeb.framework/GSWComponentRequestHandler.m: handle WO/GSWeb names
* GSWeb.framework/GSWDirectAction.m: handle WO/GSWeb names
* GSWeb.framework/GSWForm.m/.h: handle WO/GSWeb names
* GSWeb.framework/GSWHyperlink.m/.h: handle WO/GSWeb names
* GSWeb.framework/GSWResourceRequestHandler.m: handle WO/GSWeb names
* GSWeb.framework/GSWDirectActionRequestHandler.m: handle WO/GSWeb names
* GSWeb.framework/GSWActiveImage.m/.h: handle WO/GSWeb names
* GSWeb.framework/GSWBindingNameAssociation.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWBrowser.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWComponent.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWHTMLURLValuedElement.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWImageButton.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWInput.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWPopUpButton.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWString.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWAssociation.m: handle WO/GSWeb names
* GSWeb.framework/GSWCheckBox.m: handle WO/GSWeb names
* GSWeb.framework/GSWCheckBoxList.m: handle WO/GSWeb names
* GSWeb.framework/GSWComponentDefinition.m: handle WO/GSWeb names
* GSWeb.framework/GSWRadioButton.m: handle WO/GSWeb names
* GSWeb.framework/GSWRadioButtonList.m: handle WO/GSWeb names
* GSWeb.framework/GSWText.m: handle WO/GSWeb names
* GSWeb.framework/GSWTextField.m: handle WO/GSWeb names
* GSWeb.framework/GSWDeployedBundle.m: warnings
* GSWeb.framework/GSWeb.h: added include GSWeb/GSWSessionTimeOut.h, GSWWOCompatibility.h
* GSWeb.framework/GSWAdaptor.m: traces
* GSWeb.framework/GSWDefaultAdaptor.m: handle WO/GSWeb names, added traces
* GSWeb.framework/GSWDefaultAdaptorThread.m/.h: handle WO/GSWeb names
* GSWeb.framework/NSNonBlockingFileHandle.m: added traces
* GSWeb.framework/GSWTemplateParserANTLR.m: handle WO/GSWeb names
* GSWeb.framework/GSWTemplateParserXML.m: handle WO/GSWeb names
added tag count to help errors hunt
remove "Tag gsweb invalid" message
handle unicode strings in node content traces
remove html and body tags if they are not present in the template
* GSWeb.framework/GSWTemplateParseXML.h: added ivar _isHTMLTag, _isBodyTag
* GSWeb.framework/GSWSessionTimeOutManager.m: dealloc sessionOrderedTimeOuts instead
of deallocating 2 times sessionTimeOuts
* GSWExtensions.framework/French.lproj/GSWSessionRestorationErrorPage.gswc/GSWSessionRestorationErrorPage.html:
tag mismatch, Encode french characters
* GSWExtensions.framework/GSWSessionRestorationErrorPage.gswc/GSWSessionRestorationErrorPage.html:
tag mismatch
* GSWHTMLBareString.m: handle unicode strings in description
* GSWExtensions.framework/French.lproj/GSWExceptionPage.gswc/GSWExceptionPage.html:
Encode french characters, Tag Mismatch
* GSWExtensions.framework/French.lproj/GSWPageRestorationErrorPage.gswc/GSWPageRestorationErrorPage.html:
Encode french characters
* GSWExtensions.framework/French.lproj/GSWSessionCreationErrorPage.gswc/GSWSessionCreationErrorPage.html:
Encode french characters
* GSWExtensions.framework/GSWExceptionPage.gswc/GSWExceptionPage.html:
Tag Mismatch
* GSWExtensions.framework/GSWExceptionPage.gswc/GSWExceptionPage.gswd:
added convertHTMLEntities for strings
* GSWeb.framework/GSWRepetition.m: added traces, fix "count" property bug, standardize ivars
* GSWeb.framework/NSObject+IVarAccess+PerformSel.m: added traces, handle underscored ivars search
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@9332 72102866-910b-0410-8b05-ffd578937521
2001-03-11 17:15:44 +00:00
|
|
|
NSDebugMLog(@"Init");
|
2002-03-06 23:13:23 +00:00
|
|
|
if ((self=[super initWithName:name
|
|
|
|
arguments:arguments]))
|
2001-03-11 Manuel Guesdon <mguesdon@orange-concept.com>
* GSWeb.framework/GSWWOCompatibility.h/.m: added
* GSWeb.framework/GNUmakefile: added GSWWOCompatibility.h/.m
* GSWeb.framework/GSWApplication.h/m: added WOApplicationMain, handle WO/GSWeb names
* GSWeb.framework/GSWContext.m: handle WO/GSWeb names, added traces
* GSWeb.framework/GSWConstants.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWDynamicURLString.m: handle WO/GSWeb names
* GSWeb.framework/GSWProjectBundle.m/.h: handle WO/GSWeb names, suppress warnings
* GSWeb.framework/GSWSession.m: handle WO/GSWeb names
* GSWeb.framework/GSWRequest.m: handle WO/GSWeb names
* GSWeb.framework/GSWTemplateParser.m: handle WO/GSWeb names,
added tag counts to help errors hunt
* GSWeb.framework/GSWBundle.m: handle WO/GSWeb names, added traces
* GSWeb.framework/GSWResourceManager.m: handle WO/GSWeb names
* GSWeb.framework/GSWURLValuedElementData.m: handle WO/GSWeb names
* GSWeb.framework/GSWComponentRequestHandler.m: handle WO/GSWeb names
* GSWeb.framework/GSWDirectAction.m: handle WO/GSWeb names
* GSWeb.framework/GSWForm.m/.h: handle WO/GSWeb names
* GSWeb.framework/GSWHyperlink.m/.h: handle WO/GSWeb names
* GSWeb.framework/GSWResourceRequestHandler.m: handle WO/GSWeb names
* GSWeb.framework/GSWDirectActionRequestHandler.m: handle WO/GSWeb names
* GSWeb.framework/GSWActiveImage.m/.h: handle WO/GSWeb names
* GSWeb.framework/GSWBindingNameAssociation.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWBrowser.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWComponent.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWHTMLURLValuedElement.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWImageButton.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWInput.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWPopUpButton.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWString.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWAssociation.m: handle WO/GSWeb names
* GSWeb.framework/GSWCheckBox.m: handle WO/GSWeb names
* GSWeb.framework/GSWCheckBoxList.m: handle WO/GSWeb names
* GSWeb.framework/GSWComponentDefinition.m: handle WO/GSWeb names
* GSWeb.framework/GSWRadioButton.m: handle WO/GSWeb names
* GSWeb.framework/GSWRadioButtonList.m: handle WO/GSWeb names
* GSWeb.framework/GSWText.m: handle WO/GSWeb names
* GSWeb.framework/GSWTextField.m: handle WO/GSWeb names
* GSWeb.framework/GSWDeployedBundle.m: warnings
* GSWeb.framework/GSWeb.h: added include GSWeb/GSWSessionTimeOut.h, GSWWOCompatibility.h
* GSWeb.framework/GSWAdaptor.m: traces
* GSWeb.framework/GSWDefaultAdaptor.m: handle WO/GSWeb names, added traces
* GSWeb.framework/GSWDefaultAdaptorThread.m/.h: handle WO/GSWeb names
* GSWeb.framework/NSNonBlockingFileHandle.m: added traces
* GSWeb.framework/GSWTemplateParserANTLR.m: handle WO/GSWeb names
* GSWeb.framework/GSWTemplateParserXML.m: handle WO/GSWeb names
added tag count to help errors hunt
remove "Tag gsweb invalid" message
handle unicode strings in node content traces
remove html and body tags if they are not present in the template
* GSWeb.framework/GSWTemplateParseXML.h: added ivar _isHTMLTag, _isBodyTag
* GSWeb.framework/GSWSessionTimeOutManager.m: dealloc sessionOrderedTimeOuts instead
of deallocating 2 times sessionTimeOuts
* GSWExtensions.framework/French.lproj/GSWSessionRestorationErrorPage.gswc/GSWSessionRestorationErrorPage.html:
tag mismatch, Encode french characters
* GSWExtensions.framework/GSWSessionRestorationErrorPage.gswc/GSWSessionRestorationErrorPage.html:
tag mismatch
* GSWHTMLBareString.m: handle unicode strings in description
* GSWExtensions.framework/French.lproj/GSWExceptionPage.gswc/GSWExceptionPage.html:
Encode french characters, Tag Mismatch
* GSWExtensions.framework/French.lproj/GSWPageRestorationErrorPage.gswc/GSWPageRestorationErrorPage.html:
Encode french characters
* GSWExtensions.framework/French.lproj/GSWSessionCreationErrorPage.gswc/GSWSessionCreationErrorPage.html:
Encode french characters
* GSWExtensions.framework/GSWExceptionPage.gswc/GSWExceptionPage.html:
Tag Mismatch
* GSWExtensions.framework/GSWExceptionPage.gswc/GSWExceptionPage.gswd:
added convertHTMLEntities for strings
* GSWeb.framework/GSWRepetition.m: added traces, fix "count" property bug, standardize ivars
* GSWeb.framework/NSObject+IVarAccess+PerformSel.m: added traces, handle underscored ivars search
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@9332 72102866-910b-0410-8b05-ffd578937521
2001-03-11 17:15:44 +00:00
|
|
|
{
|
2002-03-06 23:13:23 +00:00
|
|
|
_fileHandle=nil;
|
|
|
|
_threads=[NSMutableArray new];
|
|
|
|
_waitingThreads=[NSMutableArray new];
|
|
|
|
_selfLock=[NSLock new];
|
|
|
|
_port=[[arguments objectForKey:GSWOPT_Port[GSWebNamingConv]] intValue];
|
|
|
|
ASSIGN(_host,[arguments objectForKey:GSWOPT_Host[GSWebNamingConv]]);
|
2001-03-11 Manuel Guesdon <mguesdon@orange-concept.com>
* GSWeb.framework/GSWWOCompatibility.h/.m: added
* GSWeb.framework/GNUmakefile: added GSWWOCompatibility.h/.m
* GSWeb.framework/GSWApplication.h/m: added WOApplicationMain, handle WO/GSWeb names
* GSWeb.framework/GSWContext.m: handle WO/GSWeb names, added traces
* GSWeb.framework/GSWConstants.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWDynamicURLString.m: handle WO/GSWeb names
* GSWeb.framework/GSWProjectBundle.m/.h: handle WO/GSWeb names, suppress warnings
* GSWeb.framework/GSWSession.m: handle WO/GSWeb names
* GSWeb.framework/GSWRequest.m: handle WO/GSWeb names
* GSWeb.framework/GSWTemplateParser.m: handle WO/GSWeb names,
added tag counts to help errors hunt
* GSWeb.framework/GSWBundle.m: handle WO/GSWeb names, added traces
* GSWeb.framework/GSWResourceManager.m: handle WO/GSWeb names
* GSWeb.framework/GSWURLValuedElementData.m: handle WO/GSWeb names
* GSWeb.framework/GSWComponentRequestHandler.m: handle WO/GSWeb names
* GSWeb.framework/GSWDirectAction.m: handle WO/GSWeb names
* GSWeb.framework/GSWForm.m/.h: handle WO/GSWeb names
* GSWeb.framework/GSWHyperlink.m/.h: handle WO/GSWeb names
* GSWeb.framework/GSWResourceRequestHandler.m: handle WO/GSWeb names
* GSWeb.framework/GSWDirectActionRequestHandler.m: handle WO/GSWeb names
* GSWeb.framework/GSWActiveImage.m/.h: handle WO/GSWeb names
* GSWeb.framework/GSWBindingNameAssociation.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWBrowser.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWComponent.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWHTMLURLValuedElement.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWImageButton.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWInput.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWPopUpButton.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWString.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWAssociation.m: handle WO/GSWeb names
* GSWeb.framework/GSWCheckBox.m: handle WO/GSWeb names
* GSWeb.framework/GSWCheckBoxList.m: handle WO/GSWeb names
* GSWeb.framework/GSWComponentDefinition.m: handle WO/GSWeb names
* GSWeb.framework/GSWRadioButton.m: handle WO/GSWeb names
* GSWeb.framework/GSWRadioButtonList.m: handle WO/GSWeb names
* GSWeb.framework/GSWText.m: handle WO/GSWeb names
* GSWeb.framework/GSWTextField.m: handle WO/GSWeb names
* GSWeb.framework/GSWDeployedBundle.m: warnings
* GSWeb.framework/GSWeb.h: added include GSWeb/GSWSessionTimeOut.h, GSWWOCompatibility.h
* GSWeb.framework/GSWAdaptor.m: traces
* GSWeb.framework/GSWDefaultAdaptor.m: handle WO/GSWeb names, added traces
* GSWeb.framework/GSWDefaultAdaptorThread.m/.h: handle WO/GSWeb names
* GSWeb.framework/NSNonBlockingFileHandle.m: added traces
* GSWeb.framework/GSWTemplateParserANTLR.m: handle WO/GSWeb names
* GSWeb.framework/GSWTemplateParserXML.m: handle WO/GSWeb names
added tag count to help errors hunt
remove "Tag gsweb invalid" message
handle unicode strings in node content traces
remove html and body tags if they are not present in the template
* GSWeb.framework/GSWTemplateParseXML.h: added ivar _isHTMLTag, _isBodyTag
* GSWeb.framework/GSWSessionTimeOutManager.m: dealloc sessionOrderedTimeOuts instead
of deallocating 2 times sessionTimeOuts
* GSWExtensions.framework/French.lproj/GSWSessionRestorationErrorPage.gswc/GSWSessionRestorationErrorPage.html:
tag mismatch, Encode french characters
* GSWExtensions.framework/GSWSessionRestorationErrorPage.gswc/GSWSessionRestorationErrorPage.html:
tag mismatch
* GSWHTMLBareString.m: handle unicode strings in description
* GSWExtensions.framework/French.lproj/GSWExceptionPage.gswc/GSWExceptionPage.html:
Encode french characters, Tag Mismatch
* GSWExtensions.framework/French.lproj/GSWPageRestorationErrorPage.gswc/GSWPageRestorationErrorPage.html:
Encode french characters
* GSWExtensions.framework/French.lproj/GSWSessionCreationErrorPage.gswc/GSWSessionCreationErrorPage.html:
Encode french characters
* GSWExtensions.framework/GSWExceptionPage.gswc/GSWExceptionPage.html:
Tag Mismatch
* GSWExtensions.framework/GSWExceptionPage.gswc/GSWExceptionPage.gswd:
added convertHTMLEntities for strings
* GSWeb.framework/GSWRepetition.m: added traces, fix "count" property bug, standardize ivars
* GSWeb.framework/NSObject+IVarAccess+PerformSel.m: added traces, handle underscored ivars search
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@9332 72102866-910b-0410-8b05-ffd578937521
2001-03-11 17:15:44 +00:00
|
|
|
// [self setInstance:_instance];
|
2002-03-06 23:13:23 +00:00
|
|
|
_queueSize=[[arguments objectForKey:GSWOPT_ListenQueueSize[GSWebNamingConv]] intValue];
|
|
|
|
_workerThreadCount=[[arguments objectForKey:GSWOPT_WorkerThreadCount[GSWebNamingConv]] intValue];
|
|
|
|
_isMultiThreadEnabled=[[arguments objectForKey:GSWOPT_MultiThreadEnabled] boolValue];
|
|
|
|
ASSIGN(_adaptorHost,[arguments objectForKey:GSWOPT_AdaptorHost[GSWebNamingConv]]);
|
2001-03-11 Manuel Guesdon <mguesdon@orange-concept.com>
* GSWeb.framework/GSWWOCompatibility.h/.m: added
* GSWeb.framework/GNUmakefile: added GSWWOCompatibility.h/.m
* GSWeb.framework/GSWApplication.h/m: added WOApplicationMain, handle WO/GSWeb names
* GSWeb.framework/GSWContext.m: handle WO/GSWeb names, added traces
* GSWeb.framework/GSWConstants.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWDynamicURLString.m: handle WO/GSWeb names
* GSWeb.framework/GSWProjectBundle.m/.h: handle WO/GSWeb names, suppress warnings
* GSWeb.framework/GSWSession.m: handle WO/GSWeb names
* GSWeb.framework/GSWRequest.m: handle WO/GSWeb names
* GSWeb.framework/GSWTemplateParser.m: handle WO/GSWeb names,
added tag counts to help errors hunt
* GSWeb.framework/GSWBundle.m: handle WO/GSWeb names, added traces
* GSWeb.framework/GSWResourceManager.m: handle WO/GSWeb names
* GSWeb.framework/GSWURLValuedElementData.m: handle WO/GSWeb names
* GSWeb.framework/GSWComponentRequestHandler.m: handle WO/GSWeb names
* GSWeb.framework/GSWDirectAction.m: handle WO/GSWeb names
* GSWeb.framework/GSWForm.m/.h: handle WO/GSWeb names
* GSWeb.framework/GSWHyperlink.m/.h: handle WO/GSWeb names
* GSWeb.framework/GSWResourceRequestHandler.m: handle WO/GSWeb names
* GSWeb.framework/GSWDirectActionRequestHandler.m: handle WO/GSWeb names
* GSWeb.framework/GSWActiveImage.m/.h: handle WO/GSWeb names
* GSWeb.framework/GSWBindingNameAssociation.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWBrowser.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWComponent.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWHTMLURLValuedElement.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWImageButton.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWInput.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWPopUpButton.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWString.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWAssociation.m: handle WO/GSWeb names
* GSWeb.framework/GSWCheckBox.m: handle WO/GSWeb names
* GSWeb.framework/GSWCheckBoxList.m: handle WO/GSWeb names
* GSWeb.framework/GSWComponentDefinition.m: handle WO/GSWeb names
* GSWeb.framework/GSWRadioButton.m: handle WO/GSWeb names
* GSWeb.framework/GSWRadioButtonList.m: handle WO/GSWeb names
* GSWeb.framework/GSWText.m: handle WO/GSWeb names
* GSWeb.framework/GSWTextField.m: handle WO/GSWeb names
* GSWeb.framework/GSWDeployedBundle.m: warnings
* GSWeb.framework/GSWeb.h: added include GSWeb/GSWSessionTimeOut.h, GSWWOCompatibility.h
* GSWeb.framework/GSWAdaptor.m: traces
* GSWeb.framework/GSWDefaultAdaptor.m: handle WO/GSWeb names, added traces
* GSWeb.framework/GSWDefaultAdaptorThread.m/.h: handle WO/GSWeb names
* GSWeb.framework/NSNonBlockingFileHandle.m: added traces
* GSWeb.framework/GSWTemplateParserANTLR.m: handle WO/GSWeb names
* GSWeb.framework/GSWTemplateParserXML.m: handle WO/GSWeb names
added tag count to help errors hunt
remove "Tag gsweb invalid" message
handle unicode strings in node content traces
remove html and body tags if they are not present in the template
* GSWeb.framework/GSWTemplateParseXML.h: added ivar _isHTMLTag, _isBodyTag
* GSWeb.framework/GSWSessionTimeOutManager.m: dealloc sessionOrderedTimeOuts instead
of deallocating 2 times sessionTimeOuts
* GSWExtensions.framework/French.lproj/GSWSessionRestorationErrorPage.gswc/GSWSessionRestorationErrorPage.html:
tag mismatch, Encode french characters
* GSWExtensions.framework/GSWSessionRestorationErrorPage.gswc/GSWSessionRestorationErrorPage.html:
tag mismatch
* GSWHTMLBareString.m: handle unicode strings in description
* GSWExtensions.framework/French.lproj/GSWExceptionPage.gswc/GSWExceptionPage.html:
Encode french characters, Tag Mismatch
* GSWExtensions.framework/French.lproj/GSWPageRestorationErrorPage.gswc/GSWPageRestorationErrorPage.html:
Encode french characters
* GSWExtensions.framework/French.lproj/GSWSessionCreationErrorPage.gswc/GSWSessionCreationErrorPage.html:
Encode french characters
* GSWExtensions.framework/GSWExceptionPage.gswc/GSWExceptionPage.html:
Tag Mismatch
* GSWExtensions.framework/GSWExceptionPage.gswc/GSWExceptionPage.gswd:
added convertHTMLEntities for strings
* GSWeb.framework/GSWRepetition.m: added traces, fix "count" property bug, standardize ivars
* GSWeb.framework/NSObject+IVarAccess+PerformSel.m: added traces, handle underscored ivars search
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@9332 72102866-910b-0410-8b05-ffd578937521
2001-03-11 17:15:44 +00:00
|
|
|
};
|
|
|
|
LOGObjectFnStop();
|
2000-01-22 12:49:49 +00:00
|
|
|
return self;
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(void)dealloc
|
|
|
|
{
|
2002-03-06 23:13:23 +00:00
|
|
|
GSWLogMemC("Dealloc GSWDefaultAdaptor");
|
2000-01-22 12:49:49 +00:00
|
|
|
//TODO? DESTROY(listenPortObject);
|
2002-03-06 23:13:23 +00:00
|
|
|
GSWLogMemC("Dealloc GSWDefaultAdaptor: host");
|
|
|
|
DESTROY(_host);
|
|
|
|
GSWLogMemC("Dealloc GSWDefaultAdaptor: adaptorHost");
|
|
|
|
DESTROY(_adaptorHost);
|
|
|
|
GSWLogMemC("Dealloc GSWDefaultAdaptor: fileHandle");
|
|
|
|
DESTROY(_fileHandle);
|
|
|
|
GSWLogMemC("Dealloc GSWDefaultAdaptor: threads");
|
|
|
|
DESTROY(_threads);
|
|
|
|
GSWLogMemC("Dealloc GSWDefaultAdaptor: waitingThreads");
|
|
|
|
DESTROY(_waitingThreads);
|
|
|
|
GSWLogMemC("Dealloc GSWDefaultAdaptor: selfLock");
|
|
|
|
DESTROY(_selfLock);
|
|
|
|
GSWLogMemC("Dealloc GSWDefaultAdaptor Super");
|
2000-01-22 12:49:49 +00:00
|
|
|
[super dealloc];
|
2002-03-06 23:13:23 +00:00
|
|
|
GSWLogMemC("End Dealloc GSWDefaultAdaptor");
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(void)registerForEvents
|
|
|
|
{
|
2002-03-06 23:13:23 +00:00
|
|
|
NSDebugDeepMLog(@"START registerForEvents - ThreadID=%p",(void*)objc_thread_id());
|
|
|
|
NSAssert(!_fileHandle,@"fileHandle already exists");
|
|
|
|
NSDebugDeepMLLog(@"info",@"registerForEvents port=%d",_port);
|
|
|
|
NSDebugDeepMLLog(@"info",@"registerForEvents host=%@",_host);
|
|
|
|
if (!_host)
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2002-03-06 23:13:23 +00:00
|
|
|
ASSIGN(_host,[[NSHost currentHost] name]);
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
2002-03-06 23:13:23 +00:00
|
|
|
_fileHandle=[[NSFileHandle fileHandleAsServerAtAddress:_host
|
|
|
|
service:[NSString stringWithFormat:@"%d",_port]
|
2000-01-22 12:49:49 +00:00
|
|
|
protocol:@"tcp"] retain];
|
2002-03-06 23:13:23 +00:00
|
|
|
NSDebugDeepMLLog(@"info",@"fileHandle=%p\n",(void*)_fileHandle);
|
2000-01-22 12:49:49 +00:00
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
|
|
selector: @selector(announceNewConnection:)
|
|
|
|
name: NSFileHandleConnectionAcceptedNotification
|
2002-03-06 23:13:23 +00:00
|
|
|
object:_fileHandle];
|
2000-01-22 12:49:49 +00:00
|
|
|
/* [NotificationDispatcher addObserver:self
|
|
|
|
selector: @selector(announceNewConnection:)
|
|
|
|
name: NSFileHandleConnectionAcceptedNotification
|
|
|
|
object:fileHandle];
|
|
|
|
*/
|
2002-03-06 23:13:23 +00:00
|
|
|
[_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(),
|
|
|
|
_host,
|
|
|
|
_port];
|
|
|
|
NSDebugDeepMLog(@"STOP registerForEvents");
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(void)unregisterForEvents
|
|
|
|
{
|
|
|
|
[[NSNotificationCenter defaultCenter] removeObserver:self
|
2002-03-06 23:13:23 +00:00
|
|
|
name:NSFileHandleConnectionAcceptedNotification
|
|
|
|
object:_fileHandle];
|
2000-01-22 12:49:49 +00:00
|
|
|
/* [NotificationDispatcher removeObserver:self
|
|
|
|
name: NSFileHandleConnectionAcceptedNotification
|
|
|
|
object:fileHandle];
|
|
|
|
*/
|
2002-03-06 23:13:23 +00:00
|
|
|
DESTROY(_fileHandle);
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-03-06 23:13:23 +00:00
|
|
|
-(void)logWithFormat:(NSString*)format,...
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
LOGObjectFnNotImplemented(); //TODOFN
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-03-06 23:13:23 +00:00
|
|
|
+(void)logWithFormat:(NSString*)format,...
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
LOGClassFnNotImplemented(); //TODOFN
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(void)runOnce
|
|
|
|
{
|
|
|
|
//call doesBusyRunOnce
|
|
|
|
LOGObjectFnNotImplemented(); //TODOFN
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(BOOL)doesBusyRunOnce
|
|
|
|
{
|
|
|
|
//call _runOnce
|
|
|
|
LOGObjectFnNotImplemented(); //TODOFN
|
|
|
|
return NO;
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(BOOL)dispatchesRequestsConcurrently
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(int)port
|
|
|
|
{
|
2002-03-06 23:13:23 +00:00
|
|
|
return _port;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(NSString*)host
|
|
|
|
{
|
2002-03-06 23:13:23 +00:00
|
|
|
return _host;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-03-06 23:13:23 +00:00
|
|
|
-(void)setWorkerThreadCount:(id)workerThreadCount
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
if ([self tryLock])
|
2002-03-06 23:13:23 +00:00
|
|
|
{
|
|
|
|
NS_DURING
|
|
|
|
{
|
|
|
|
_workerThreadCount=[workerThreadCount intValue];
|
|
|
|
if (_workerThreadCount<1)
|
|
|
|
_workerThreadCount=1;
|
|
|
|
}
|
|
|
|
NS_HANDLER
|
|
|
|
{
|
|
|
|
LOGException(@"%@ (%@)",
|
|
|
|
localException,
|
|
|
|
[localException reason]);
|
|
|
|
}
|
|
|
|
NS_ENDHANDLER;
|
|
|
|
[self unlock];
|
|
|
|
}
|
2000-01-22 12:49:49 +00:00
|
|
|
else
|
2002-03-06 23:13:23 +00:00
|
|
|
{
|
|
|
|
//TODO
|
|
|
|
};
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(id)workerThreadCount
|
|
|
|
{
|
2002-03-06 23:13:23 +00:00
|
|
|
return [NSNumber numberWithInt:_workerThreadCount];
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(BOOL)isMultiThreadEnabled
|
|
|
|
{
|
2002-03-06 23:13:23 +00:00
|
|
|
return _isMultiThreadEnabled;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
2002-03-06 23:13:23 +00:00
|
|
|
|
2000-01-22 12:49:49 +00:00
|
|
|
//--------------------------------------------------------------------
|
2002-03-06 23:13:23 +00:00
|
|
|
-(void)setListenQueueSize:(id)listenQueueSize
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
if ([self tryLock])
|
2002-03-06 23:13:23 +00:00
|
|
|
{
|
|
|
|
NS_DURING
|
|
|
|
{
|
|
|
|
_queueSize=[listenQueueSize intValue];
|
|
|
|
if (_queueSize<1)
|
|
|
|
_queueSize=1;
|
|
|
|
}
|
|
|
|
NS_HANDLER
|
|
|
|
{
|
|
|
|
LOGException(@"%@ (%@)",
|
|
|
|
localException,
|
|
|
|
[localException reason]);
|
|
|
|
}
|
|
|
|
NS_ENDHANDLER;
|
|
|
|
[self unlock];
|
|
|
|
}
|
2000-01-22 12:49:49 +00:00
|
|
|
else
|
2002-03-06 23:13:23 +00:00
|
|
|
{
|
|
|
|
//TODO
|
|
|
|
};
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
//NDFN
|
|
|
|
-(id)announceNewConnection:(id)notification
|
|
|
|
{
|
2002-03-06 23:13:23 +00:00
|
|
|
GSWDefaultAdaptorThread* newThread=nil;
|
|
|
|
NSFileHandle* listenHandle=nil;
|
2000-01-22 12:49:49 +00:00
|
|
|
NSFileHandle* inStream = nil;
|
2000-03-16 16:16:49 +00:00
|
|
|
NSCalendarDate* requestDate=nil;
|
|
|
|
NSString* requestDateString=nil;
|
2002-03-06 23:13:23 +00:00
|
|
|
NSString* connRefusedMessage=nil;
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStart();
|
2002-03-06 23:13:23 +00:00
|
|
|
listenHandle=[notification object];
|
2000-03-16 16:16:49 +00:00
|
|
|
requestDate=[NSCalendarDate calendarDate];
|
2001-10-28 10:29:17 +00:00
|
|
|
requestDateString=[NSString stringWithFormat:@"ThreadID=%p: New Request %@",(void*)objc_thread_id(),requestDate];
|
2000-03-20 15:50:51 +00:00
|
|
|
[GSWApplication statusLogWithFormat:@"%@",requestDateString];
|
2002-03-06 23:13:23 +00:00
|
|
|
NSDebugDeepMLLog(@"info",@"listenHandle=%p",(void*)listenHandle);
|
2000-01-22 12:49:49 +00:00
|
|
|
inStream = [[notification userInfo]objectForKey:@"NSFileHandleNotificationFileHandleItem"];
|
2002-03-06 23:13:23 +00:00
|
|
|
NSDebugDeepMLog(@"ThreadID=%p announceNewConnection notification=%@ socketAddress=%@ [notification userInfo]=%p\n",
|
|
|
|
(void*)objc_thread_id(),
|
|
|
|
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(),
|
|
|
|
(int)[_fileHandle readInProgress]);
|
|
|
|
[GSWDefaultAdaptorThread sendConnectionRefusedResponseToStream:inStream
|
|
|
|
withMessage:connRefusedMessage];
|
|
|
|
inStream=nil;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NSDebugDeepMLLog(@"info",@"notification userInfo=%@\n",
|
|
|
|
[notification userInfo]);
|
|
|
|
NSDebugDeepMLog(@"ThreadID=%p - A1 readInProgress=%d",
|
|
|
|
(void*)objc_thread_id(),
|
|
|
|
(int)[_fileHandle readInProgress]);
|
|
|
|
NSDebugDeepMLLog(@"ThreadID=%p - A1 readInProgress=%d\n",
|
|
|
|
(void*)objc_thread_id(),
|
|
|
|
(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);
|
|
|
|
if ([_waitingThreads count]>=_queueSize)
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2001-10-28 10:29:17 +00:00
|
|
|
//remove expired thread
|
|
|
|
if ([self tryLock])
|
|
|
|
{
|
|
|
|
NSDebugMLog0(@"locked !");
|
|
|
|
NS_DURING
|
|
|
|
{
|
|
|
|
int i=0;
|
|
|
|
GSWDefaultAdaptorThread* thread=nil;
|
2002-03-06 23:13:23 +00:00
|
|
|
for(i=0;i<[_waitingThreads count];)
|
2001-10-28 10:29:17 +00:00
|
|
|
{
|
2002-03-06 23:13:23 +00:00
|
|
|
thread=[_waitingThreads objectAtIndex:i];
|
2001-10-28 10:29:17 +00:00
|
|
|
if ([thread isExpired])
|
|
|
|
{
|
|
|
|
// [GSWDefaultAdaptorThread sendRetryLasterResponseToStream:[thread stream]];
|
2002-03-06 23:13:23 +00:00
|
|
|
[_waitingThreads removeObjectAtIndex:i];
|
2001-10-28 10:29:17 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
i++;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
NS_HANDLER
|
|
|
|
{
|
|
|
|
LOGException(@"%@ (%@)",
|
|
|
|
localException,[localException reason]);
|
|
|
|
//TODO
|
|
|
|
[self unlock];
|
|
|
|
[localException raise];
|
|
|
|
}
|
|
|
|
NS_ENDHANDLER;
|
|
|
|
[self unlock];
|
|
|
|
};
|
|
|
|
};
|
2002-03-06 23:13:23 +00:00
|
|
|
if ([_waitingThreads count]>=_queueSize)
|
|
|
|
{
|
|
|
|
NSDebugDeepMLog(@"DESTROY the connection: too many conn - ThreadID=%p - A1 readInProgress=%d\n",
|
|
|
|
(void*)objc_thread_id(),
|
|
|
|
(int)[_fileHandle readInProgress]);
|
|
|
|
[GSWDefaultAdaptorThread sendRetryLasterResponseToStream:inStream];
|
|
|
|
inStream=nil;
|
|
|
|
}
|
|
|
|
else
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
//release done after lock !
|
2002-03-06 23:13:23 +00:00
|
|
|
newThread=[[GSWDefaultAdaptorThread alloc] initWithApp:[GSWApplication application]
|
|
|
|
withAdaptor:self
|
|
|
|
withStream:inStream];
|
|
|
|
if (newThread)
|
|
|
|
{
|
|
|
|
NSDebugLockMLog0(@"_newThread !");
|
|
|
|
if ([self tryLock])
|
|
|
|
{
|
|
|
|
NSDebugLockMLog0(@"locked !");
|
|
|
|
NS_DURING
|
|
|
|
{
|
|
|
|
NSDebugLockMLLog(@"low",
|
|
|
|
@"[waitingThreads count]=%d [threads count]=%d",
|
|
|
|
[_waitingThreads count],
|
|
|
|
[_threads count]);
|
|
|
|
if ([_threads count]<_workerThreadCount)
|
|
|
|
{
|
|
|
|
[_threads addObject:newThread];
|
|
|
|
NSDebugLockMLLog(@"trace",@"isMultiThreadEnabled=%d",
|
|
|
|
_isMultiThreadEnabled);
|
|
|
|
if (_isMultiThreadEnabled)
|
|
|
|
{
|
|
|
|
requestDate=[NSCalendarDate calendarDate];
|
|
|
|
requestDateString=[NSString stringWithFormat:@"ThreadID=%p : Lauch Thread (Multi) %@",
|
|
|
|
(void*)objc_thread_id(),
|
|
|
|
requestDate];
|
|
|
|
[GSWApplication statusLogWithFormat:@"%@",requestDateString];
|
|
|
|
NSDebugLockMLLog(@"info",
|
|
|
|
@"ThreadID=%p : Lauch Thread (Multi) %p",
|
|
|
|
(void*)objc_thread_id(),
|
|
|
|
(void*)newThread);
|
|
|
|
[NSThread detachNewThreadSelector:@selector(run:)
|
|
|
|
toTarget:newThread
|
|
|
|
withObject:nil];
|
|
|
|
DESTROY(newThread);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//Runit after
|
|
|
|
/*
|
|
|
|
[GSWApplication statusLogWithFormat:@"Lauch Thread (Mono)"];
|
|
|
|
NSDebugMLLog(@"info",
|
|
|
|
@"Lauch Thread (Mono) %p",
|
|
|
|
(void*)_newThread);
|
|
|
|
[_newThread run:nil];
|
|
|
|
*/
|
|
|
|
};
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[GSWApplication statusLogWithFormat:@"Set Thread to wait"];
|
|
|
|
NSDebugLockMLLog(@"info",
|
|
|
|
@"Set Thread to wait %p",
|
|
|
|
(void*)newThread);
|
|
|
|
[_waitingThreads addObject:newThread];
|
|
|
|
DESTROY(newThread);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
NS_HANDLER
|
|
|
|
{
|
|
|
|
LOGException(@"%@ (%@)",
|
|
|
|
localException,[localException reason]);
|
|
|
|
//TODO
|
|
|
|
[self unlock];
|
|
|
|
[localException raise];
|
|
|
|
}
|
|
|
|
NS_ENDHANDLER;
|
|
|
|
[self unlock];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DESTROY(newThread);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
if (!_isMultiThreadEnabled && newThread)
|
|
|
|
{
|
|
|
|
requestDate=[NSCalendarDate calendarDate];
|
|
|
|
requestDateString=[NSString stringWithFormat:@"Lauch Thread (Mono) %@",requestDate];
|
|
|
|
[GSWApplication statusLogWithFormat:@"%@",requestDateString];
|
|
|
|
NSDebugLockMLLog(@"info",
|
|
|
|
@"%@ %p",
|
|
|
|
requestDateString,
|
|
|
|
(void*)newThread);
|
|
|
|
[newThread run:nil];
|
|
|
|
DESTROY(newThread);
|
|
|
|
requestDate=[NSCalendarDate calendarDate];
|
|
|
|
requestDateString=[NSString stringWithFormat:@"Stop Thread (Mono) %@",requestDate];
|
|
|
|
[GSWApplication statusLogWithFormat:@"%@",requestDateString];
|
|
|
|
NSDebugLockMLLog0(@"info",
|
|
|
|
requestDateString);
|
|
|
|
};
|
2001-10-28 10:29:17 +00:00
|
|
|
};
|
2002-03-06 23:13:23 +00:00
|
|
|
};
|
|
|
|
NSDebugLockMLLog(@"trace",@"Try Lock");
|
2001-10-28 10:29:17 +00:00
|
|
|
if ([self tryLock])
|
|
|
|
{
|
|
|
|
BOOL accept=YES;//NEW[waitingThreads count]<queueSize;
|
2002-03-06 23:13:23 +00:00
|
|
|
NSDebugLockMLLog(@"trace",@"Accept=%d",accept);
|
2001-10-28 10:29:17 +00:00
|
|
|
NS_DURING
|
|
|
|
{
|
|
|
|
if (accept)
|
|
|
|
{
|
2002-03-06 23:13:23 +00:00
|
|
|
[listenHandle acceptConnectionInBackgroundAndNotify];
|
|
|
|
_blocked=NO;
|
|
|
|
NSDebugDeepMLog(@"ACCEPT ThreadID=%p A2 readInProgress=%d\n",
|
|
|
|
(void*)objc_thread_id(),(int)[_fileHandle readInProgress]);
|
2001-10-28 10:29:17 +00:00
|
|
|
}
|
|
|
|
else
|
2002-03-06 23:13:23 +00:00
|
|
|
{
|
|
|
|
NSDebugDeepMLog(@"NOT ACCEPT ThreadID=%p A2 readInProgress=%d\n",
|
|
|
|
(void*)objc_thread_id(),(int)[_fileHandle readInProgress]);
|
|
|
|
};
|
|
|
|
NSDebugLockMLog(@"ThreadID=%p A2 readInProgress=%d",
|
|
|
|
(void*)objc_thread_id(),(int)[_fileHandle readInProgress]);
|
2001-10-28 10:29:17 +00:00
|
|
|
}
|
|
|
|
NS_HANDLER
|
|
|
|
{
|
|
|
|
LOGException(@"%@ (%@)",
|
|
|
|
localException,[localException reason]);
|
|
|
|
//TODO
|
2002-03-06 23:13:23 +00:00
|
|
|
_blocked=!accept;
|
2001-10-28 10:29:17 +00:00
|
|
|
[self unlock];
|
|
|
|
[localException raise];
|
|
|
|
}
|
|
|
|
NS_ENDHANDLER;
|
2002-03-06 23:13:23 +00:00
|
|
|
_blocked=!accept;
|
|
|
|
printf("blocked=%d",_blocked);
|
2001-10-28 10:29:17 +00:00
|
|
|
[self unlock];
|
|
|
|
};
|
2002-03-06 23:13:23 +00:00
|
|
|
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);
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
|
|
|
return self;
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-03-06 23:13:23 +00:00
|
|
|
-(void)adaptorThreadExited:(GSWDefaultAdaptorThread*)adaptorThread
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
LOGObjectFnStart();
|
2001-10-28 10:29:17 +00:00
|
|
|
// NSDebugMLLog(@"trace",@"adaptorThreadExited");
|
2002-03-06 23:13:23 +00:00
|
|
|
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);
|
|
|
|
|
2000-01-22 12:49:49 +00:00
|
|
|
if ([self tryLock])
|
2002-03-06 23:13:23 +00:00
|
|
|
{
|
|
|
|
NSAutoreleasePool* pool=nil;
|
2000-01-22 12:49:49 +00:00
|
|
|
#ifndef NDEBUG
|
2002-03-06 23:13:23 +00:00
|
|
|
pool=[NSAutoreleasePool new];
|
|
|
|
NSDebugLockMLLog(@"low",
|
|
|
|
@"remove thread %p",
|
|
|
|
(void*)adaptorThread);
|
|
|
|
DESTROY(pool);
|
2000-01-22 12:49:49 +00:00
|
|
|
#endif
|
2002-03-06 23:13:23 +00:00
|
|
|
NS_DURING
|
|
|
|
{
|
|
|
|
[adaptorThread retain];
|
|
|
|
[adaptorThread autorelease];
|
|
|
|
[_threads removeObject:adaptorThread];
|
|
|
|
}
|
|
|
|
NS_HANDLER
|
|
|
|
{
|
|
|
|
pool=[NSAutoreleasePool new];
|
|
|
|
LOGException(@"%@ (%@)",
|
|
|
|
localException,
|
|
|
|
[localException reason]);
|
|
|
|
DESTROY(pool);
|
|
|
|
//TODO
|
|
|
|
// [self unlock];
|
|
|
|
// [localException raise];
|
|
|
|
}
|
|
|
|
NS_ENDHANDLER;
|
2000-01-22 12:49:49 +00:00
|
|
|
#ifndef NDEBUG
|
2002-03-06 23:13:23 +00:00
|
|
|
pool=[NSAutoreleasePool new];
|
|
|
|
NSDebugLockMLLog(@"low",
|
|
|
|
@"[waitingThreads count]=%d [threads count]=%d",
|
|
|
|
[_waitingThreads count],
|
|
|
|
[_threads count]);
|
|
|
|
DESTROY(pool);
|
2000-01-22 12:49:49 +00:00
|
|
|
#endif
|
2002-03-06 23:13:23 +00:00
|
|
|
if ([_threads count]==0)
|
|
|
|
{
|
|
|
|
BOOL isApplicationRequestHandlingLocked=[[GSWApplication application] isRequestHandlingLocked];
|
|
|
|
if (isApplicationRequestHandlingLocked)
|
|
|
|
{
|
|
|
|
pool=[NSAutoreleasePool new];
|
|
|
|
LOGSeriousError0(@"Application RequestHandling is LOCKED !!!");
|
|
|
|
NSAssert(NO,@"Application RequestHandling is LOCKED !!!");//TODO-NOW
|
|
|
|
[[GSWApplication application] terminate];
|
|
|
|
DESTROY(pool);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
if ([_waitingThreads count]>0 && [_threads count]<_workerThreadCount)
|
|
|
|
{
|
|
|
|
NS_DURING
|
|
|
|
{
|
|
|
|
GSWDefaultAdaptorThread* thread=nil;
|
|
|
|
while(!thread && [_waitingThreads count]>0)
|
|
|
|
{
|
|
|
|
thread=[_waitingThreads objectAtIndex:0];
|
|
|
|
if ([thread isExpired])
|
|
|
|
{
|
|
|
|
//[GSWDefaultAdaptorThread sendRetryLasterResponseToStream:[_thread stream]];
|
|
|
|
thread=nil;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
[_threads addObject:thread];
|
|
|
|
[_waitingThreads removeObjectAtIndex:0];
|
|
|
|
};
|
|
|
|
if (thread)
|
|
|
|
{
|
2000-01-22 12:49:49 +00:00
|
|
|
#ifndef NDEBUG
|
2002-03-06 23:13:23 +00:00
|
|
|
pool=[NSAutoreleasePool new];
|
|
|
|
[GSWApplication statusLogWithFormat:@"Lauch waiting Thread"];
|
|
|
|
NSDebugLockMLLog(@"info",
|
|
|
|
@"Lauch waiting Thread %p",
|
|
|
|
(void*)thread);
|
|
|
|
DESTROY(pool);
|
2000-01-22 12:49:49 +00:00
|
|
|
#endif
|
2002-03-06 23:13:23 +00:00
|
|
|
if (_isMultiThreadEnabled)
|
|
|
|
[NSThread detachNewThreadSelector:@selector(run:)
|
|
|
|
toTarget:thread
|
|
|
|
withObject:nil];
|
|
|
|
else
|
|
|
|
[thread run:nil];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
NS_HANDLER
|
|
|
|
{
|
|
|
|
pool=[NSAutoreleasePool new];
|
|
|
|
LOGException(@"%@ (%@)",
|
|
|
|
localException,
|
|
|
|
[localException reason]);
|
|
|
|
DESTROY(pool);
|
|
|
|
//TODO
|
|
|
|
// [self unlock];
|
|
|
|
// [localException raise];
|
|
|
|
}
|
|
|
|
NS_ENDHANDLER;
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_DURING
|
|
|
|
{
|
|
|
|
BOOL accept=[_waitingThreads count]<_queueSize;
|
|
|
|
if (_blocked && accept)
|
|
|
|
{
|
|
|
|
NSDebugDeepMLog(@"ACCEPT AGAIN ThreadID=%p A2 readInProgress=%d\n",
|
|
|
|
(void*)objc_thread_id(),(int)[_fileHandle readInProgress]);
|
|
|
|
[_fileHandle acceptConnectionInBackgroundAndNotify];
|
|
|
|
_blocked=NO;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
NS_HANDLER
|
|
|
|
{
|
|
|
|
pool=[NSAutoreleasePool new];
|
|
|
|
LOGException(@"%@ (%@)",
|
|
|
|
localException,
|
|
|
|
[localException reason]);
|
|
|
|
DESTROY(pool);
|
|
|
|
//TODO
|
|
|
|
// [self unlock];
|
|
|
|
// [localException raise];
|
|
|
|
}
|
|
|
|
NS_ENDHANDLER;
|
|
|
|
|
|
|
|
[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);
|
|
|
|
// (int)(((UnixFileHandle*)fileHandle)->acceptOK));
|
|
|
|
NSDebugLockMLog(@"ThreadID=%p B2 readInProgress=%d",
|
|
|
|
(void*)objc_thread_id(),(int)[_fileHandle readInProgress]);
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
|
|
|
};
|
2001-10-28 10:29:17 +00:00
|
|
|
|
|
|
|
-(NSFileHandle*)fileHandle
|
|
|
|
{
|
2002-03-06 23:13:23 +00:00
|
|
|
return _fileHandle;
|
2001-10-28 10:29:17 +00:00
|
|
|
};
|
2000-01-22 12:49:49 +00:00
|
|
|
//--------------------------------------------------------------------
|
|
|
|
//NDFN
|
|
|
|
-(id)announceBrokenConnection:(id)notification
|
|
|
|
{
|
|
|
|
LOGObjectFnNotImplemented(); //TODOFN
|
2001-10-28 10:29:17 +00:00
|
|
|
NSDebugMLLog(@"trace",@"announceBrokenConnection");
|
2000-01-22 12:49:49 +00:00
|
|
|
// [self shutDownConnectionWithSocket:[in_port _port_socket]];
|
|
|
|
return self;
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
// lock
|
|
|
|
-(BOOL)tryLock
|
|
|
|
{
|
2002-03-06 23:13:23 +00:00
|
|
|
BOOL locked=NO;
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStart();
|
2002-03-06 23:13:23 +00:00
|
|
|
NSDebugLockMLog(@"self=%p ThreadID=%p TRYLOCK\n",
|
|
|
|
self,(void*)objc_thread_id());
|
|
|
|
locked=[_selfLock tmptryLockBeforeDate:[NSDate dateWithTimeIntervalSinceNow:90]];
|
|
|
|
NSDebugLockMLog(@"self=%p ThreadID=%p TRYLOCK LOCKED ?\n",
|
|
|
|
self,(void*)objc_thread_id());
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
2002-03-06 23:13:23 +00:00
|
|
|
return locked;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
// unlock
|
|
|
|
-(void)unlock
|
|
|
|
{
|
|
|
|
LOGObjectFnStart();
|
2002-03-06 23:13:23 +00:00
|
|
|
NSDebugLockMLog(@"self=%p ThreadID=%p UNLOCK\n",
|
|
|
|
self,(void*)objc_thread_id());
|
|
|
|
[_selfLock tmpunlock];
|
|
|
|
NSDebugLockMLog(@"self=%p ThreadID=%p UNLOCK UNLOCKED ?\n",
|
|
|
|
self,(void*)objc_thread_id());
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
|
|
|
};
|
|
|
|
|
2002-03-06 23:13:23 +00:00
|
|
|
-(BOOL)isConnectionAllowedWithHandle:(NSFileHandle*)handle
|
|
|
|
returnedMessage:(NSString**)retMessage
|
|
|
|
{
|
|
|
|
BOOL allowed=YES;
|
|
|
|
if ([_adaptorHost length]>0)
|
|
|
|
{
|
|
|
|
NSString* connAddress=[handle socketAddress];
|
|
|
|
NSDebugMLog(@"HANDLE connAddress: %@ _adaptorHost=%@",connAddress,_adaptorHost);
|
|
|
|
if ([connAddress isEqualToString:_adaptorHost])
|
|
|
|
{
|
|
|
|
[GSWApplication statusDebugWithFormat:@"ACCEPTED connection from: %@ (Allowed: %@)",
|
|
|
|
connAddress,_adaptorHost];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[GSWApplication statusLogErrorWithFormat:@"REFUSED connection from: %@ (Allowed: %@)",
|
|
|
|
connAddress,_adaptorHost];
|
|
|
|
allowed=NO;
|
|
|
|
if (retMessage)
|
|
|
|
*retMessage=@"host denied";//TODO
|
|
|
|
//TODO
|
|
|
|
};
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
#if HAVE_LIBWRAP
|
|
|
|
NSString* appName=nil;
|
|
|
|
struct request_info libwrapRequestInfo;
|
|
|
|
memset(&libwrapRequestInfo,0,sizeof(libwrapRequestInfo));
|
|
|
|
|
|
|
|
appName=[[GSWApplication application]name];
|
|
|
|
request_init(&libwrapRequestInfo, RQ_DAEMON,[appName cString], RQ_FILE, [handle fileDescriptor], 0);
|
|
|
|
|
|
|
|
fromhost(&libwrapRequestInfo);
|
|
|
|
if (STR_EQ(eval_hostname(libwrapRequestInfo.client), paranoid) || !hosts_access(&libwrapRequestInfo))
|
|
|
|
{
|
|
|
|
allowed=NO;
|
|
|
|
if (retMessage)
|
|
|
|
*retMessage=@"libwrap denied";//TODO
|
|
|
|
[GSWApplication statusDebugWithFormat:@"libwrap app: %@ REFUSED connection from: %s (%s)",
|
|
|
|
appName,
|
|
|
|
libwrapRequestInfo.client[0].name,
|
|
|
|
libwrapRequestInfo.client[0].addr];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[GSWApplication statusDebugWithFormat:@"libwrap app: %@ ACCEPTED connection from: %s (%s)",
|
|
|
|
appName,
|
|
|
|
libwrapRequestInfo.client[0].name,
|
|
|
|
libwrapRequestInfo.client[0].addr];
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
return allowed;
|
|
|
|
};
|
|
|
|
|
2000-01-22 12:49:49 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
@implementation GSWDefaultAdaptor (GSWDefaultAdaptorA)
|
|
|
|
-(void)stop
|
|
|
|
{
|
|
|
|
LOGObjectFnNotImplemented(); //TODOFN
|
|
|
|
};
|
|
|
|
|
|
|
|
-(void)run
|
|
|
|
{
|
|
|
|
LOGObjectFnNotImplemented(); //TODOFN
|
|
|
|
};
|
|
|
|
|
|
|
|
-(void)_runOnce
|
|
|
|
{
|
|
|
|
LOGObjectFnNotImplemented(); //TODOFN
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-03-06 23:13:23 +00:00
|
|
|
@end
|