2001-10-25 Manuel Guesdon <mguesdon@orange-concept.com>

Applied patch from Turbocat (www.turbocat.de): GSWPatch_04-JUL_2001.diff
		except GSWeb.framework/GSWInput.m/.h one (have to verify coherence of it)

	* GSWAdaptors/common/GSWApp.c/.h: Added GSWAppInfo
	* GSWAdaptors/common/GSWAppConnectNSSocket.c: Changes on includes
	* GSWAdaptors/common/GSWLoadBalancing.h: Added parameter to GSWLoadBalancing_Find*
	* GSWAdaptors/common/GSWLoadBalancing.c: added p_pURLComponents parameter,
		o management of AppInfo
	* GSWAdaptors/common/GSWAppRequest.c: managing refused connections
	* GSWExtensions.framework/GSWStatsPage.gswc/GSWStatsPage.gswd: misspelling correction
	* GSWExtensions.framework/GSWStatsPage.gswc/GSWStatsPage.html: Various Changes
	* GSWExtensions.framework/GSWStatsPage.m: changes in login/password validation
		o -awake added
	* GSWeb.framework/GSWApplication.m/.h: Manage refusing new sessions
	* GSWeb.framework/GSWBundle.m: debug traces commented
	* GSWeb.framework/GSWComponent.m: implementation of ensureAwakeInContext:
	* GSWeb.framework/GSWAssociation.m: special case for returned value of type GSMutableArray (Why ?)
	* GSWeb.framework/GSWComponentRequestHandler.m: comments added
	* GSWeb.framework/GSWDefaultAdaptorThread.m: added debug traces
	* GSWeb.framework/GSWDirectActionRequestHandler.m: replaced GSWDirectAction by DirectAction
	* GSWeb.framework/GSWDisplayGroup.m:  initialize _baseIndex,
		o correct misspelled names,
		o added -description,
		o use delegate in _changedInEditingContext:, _invalidatedAllObjectsInStore:,
		o changes in -deleteObjectAtIndex:,
	* GSWeb.framework/GSWFileUpload.m: different handling of _fileDatasCount,
		handle bug in omniweb-browser
	* GSWeb.framework/GSWHyperlink.m: added ensureAwakeInContext: call
	* GSWeb.framework/GSWImageButton.m: added ensureAwakeInContext: call
	* GSWeb.framework/GSWPopUpButton.m:
		o use [response_ appendContentString:_noSelectionStringValue] instead of
	  		[response_ appendContentHTMLString:_noSelectionStringValue]
		o handle no displayString case
		o use [response_ appendContentString:_displayStringValue] instead of
			  [response_ appendContentHTMLString:_displayStringValue]
	* GSWeb.framework/GSWConfig.h: set GSWOPTVALUE_AutoOpenInBrowser to NO
	* GSWeb.framework/GSWElementIDString.m: comment some debug traces
	* GSWeb.framework/GSWHTMLStaticGroup.m/.h: added support of documentType
	* GSWeb.framework/GSWHTMLURLValuedElement.m: addeded debug trace
	* GSWeb.framework/GSWKeyValueAssociation.m: use  NSStringFromClass([retValue class])
		instead of [retValue class] for log
	* GSWeb.framework/GSWRequest.m/.h: added -(NSDictionary*)headers;
		o added test on _contentType in _contentType
		o autorelease _dict in -uriElements
	* GSWeb.framework/GSWResponse.m/.h: added -setHeaders: and -headers
		o Added GSWResponse (GSWResponseRefused)
		o return self in -generateResponse
	* GSWeb.framework/GSWServerSessionStore.m/.h: added @interface GSWServerSessionStore (GSWServerSessionStoreInfo)
		o added refusing session management
	* GSWeb.framework/GSWSession.m:
		o in -terminate  forces to call removeSessionWithID in GSWServerSessionStore to dealloc it
	* GSWeb.framework/GSWSessionTimeOutManager.m/.h: replace NSMutableOrderedArray* sessionOrderedTimeOuts;
  			by NSMutableArray* sessionOrderedTimeOuts;
		o added traces
		o added  GSWSessionTimeOutManager (GSWSessionRefused)
	* GSWeb.framework/GSWSubmitButton.m: raise exception if no element is returned
	* GSWeb.framework/GSWTemplateParser.m: added doctype management
	* GSWeb.framework/GSWUtils.h: added if defined for __NetBSD__
	* GSWeb.framework/GSWWOCompatibility.m/.h: added WOGenericContainer, WOImageButton, WOHyperlink
	* GSWeb.framework/attach.m: added if defined for __NetBSD__
	* GSWeb.framework/stacktrace.m: added if defined for __NetBSD__
	* GSWeb.framework/GSWTemplateParserXML.m: traces commented
		o test XML node content before adding it
	* GSWeb.framework/NSObject+IVarAccess+PerformSel.m
		o changes in -getIVarNamed: and in setIVarNamed:withValue: (use of sel+imp, tests on parameters)
	* GSWAdaptors/common/GSWHTTPResponse.c: change in GSWHTTPResponse_GetResponse()
		o debug traces removed


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@11251 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Manuel Guesdon 2001-10-26 08:50:52 +00:00
parent 6b85738709
commit ee56247d12
51 changed files with 1505 additions and 438 deletions

View file

@ -33,7 +33,8 @@ static char rcsId[] = "$Id$";
//OK
if ((self=[super init]))
{
sessionOrderedTimeOuts=[[NSMutableOrderedArray alloc]initWithCompareSelector:@selector(compareTimeOutDate:)];
//sessionOrderedTimeOuts=[[NSMutableOrderedArray alloc]initWithCompareSelector:@selector(compareTimeOutDate:)];
sessionOrderedTimeOuts=[NSMutableArray new];
sessionTimeOuts=[NSMutableDictionary new];
// selfLock=[NSRecursiveLock new];
selfLock=[NSLock new];
@ -100,6 +101,7 @@ static char rcsId[] = "$Id$";
}
NS_HANDLER
{
NSLog(@"### exception from ... addTimer... %@", [localException reason]);
LOGException(@"%@ (%@)",localException,[localException reason]);
//TODO
[target unlock];
@ -114,6 +116,7 @@ static char rcsId[] = "$Id$";
}
NS_HANDLER
{
NSLog(@"### exception ... %@", [localException reason]);
LOGException(@"%@ (%@)",localException,[localException reason]);
//TODO
[self unlock];
@ -136,14 +139,24 @@ static char rcsId[] = "$Id$";
[self lock];
NS_DURING
{
NSEnumerator *_sessionTimeOutEnum = nil;
GSWSessionTimeOut* _sessionTimeOut=nil;
NSTimeInterval _now=[NSDate timeIntervalSinceReferenceDate];
NSTimer* _timer=nil;
int _removedNb=0;
/*
if ([sessionOrderedTimeOuts count]>0)
_sessionTimeOut=[sessionOrderedTimeOuts objectAtIndex:0];
while (/*_removedNb<20 && */_sessionTimeOut && [_sessionTimeOut timeOutTime]<_now)
*/
_sessionTimeOutEnum = [sessionOrderedTimeOuts objectEnumerator];
while (/*_removedNb<20 && *//*_sessionTimeOut && [_sessionTimeOut timeOutTime]<_now*/
_sessionTimeOut = [_sessionTimeOutEnum nextObject])
{
if ([_sessionTimeOut timeOutTime]<_now)
{
id _session=nil;
[target lock];
NS_DURING
@ -174,16 +187,25 @@ static char rcsId[] = "$Id$";
NSDebugMLLog(@"sessions",@"sessionOrderedTimeOuts=%@",sessionOrderedTimeOuts);
[_session terminate];
NSDebugMLLog(@"sessions",@"sessionOrderedTimeOuts=%@",sessionOrderedTimeOuts);
[sessionOrderedTimeOuts removeObjectAtIndex:0];
NSLog(@"GSWSessionTimeOutMananger : removeObject = %@", _sessionTimeOut);
/* [sessionOrderedTimeOuts removeObjectAtIndex:0]; */
[sessionOrderedTimeOuts removeObject:_sessionTimeOut];
[sessionTimeOuts removeObjectForKey:[_session sessionID]];
NSDebugMLLog(@"sessions",@"sessionOrderedTimeOuts=%@",sessionOrderedTimeOuts);
_removedNb++;
/*
if ([sessionOrderedTimeOuts count]>0)
_sessionTimeOut=[sessionOrderedTimeOuts objectAtIndex:0];
else
_sessionTimeOut=nil;
*/
}
else
_sessionTimeOut=nil;
};
};
_timer=[self resetTimer];
@ -230,20 +252,46 @@ static char rcsId[] = "$Id$";
NSDebugMLLog(@"sessions",@"sessionOrderedTimeOuts=%@",sessionOrderedTimeOuts);
if ([sessionOrderedTimeOuts count]>0)
{
_sessionTimeOut=[sessionOrderedTimeOuts objectAtIndex:0];
NSEnumerator * sessionOrderedTimeOutsEnum = [sessionOrderedTimeOuts objectEnumerator];
GSWSessionTimeOut* sessionTimeOutObject=nil;
NSTimeInterval _minTimeOut;
_sessionTimeOut = [sessionOrderedTimeOuts objectAtIndex:0];
_minTimeOut = [_sessionTimeOut timeOutTime];
while (sessionTimeOutObject = [sessionOrderedTimeOutsEnum nextObject]) {
if ([sessionTimeOutObject timeOutTime] < _minTimeOut) {
_sessionTimeOut = sessionTimeOutObject;
_minTimeOut = [_sessionTimeOut timeOutTime];
}
}
//_sessionTimeOut=[sessionOrderedTimeOuts objectAtIndex:0];
// search for minimum timeouts
NSDebugMLLog(@"sessions",@"_sessionTimeOut=%@",_sessionTimeOut);
NSDebugMLLog(@"sessions",@"[timer fireDate]=%@",[timer fireDate]);
NSDebugMLLog(@"sessions",@"[old timer isValide]=%s",
[timer isValid] ? "YES" : "NO");
/*
NSLog(@"_sessionTimeOut=%@",_sessionTimeOut);
NSLog(@"[old timer isValide]=%s", [timer isValid] ? "YES" : "NO");
NSLog(@"[_sessionTimeOut timeOutTime] = %ld",(long)[_sessionTimeOut timeOutTime]);
NSLog(@"_timerFireTimeInterval = %ld",(long) _timerFireTimeInterval);
NSLog(@"_now = %ld",(long) _now);
*/
if (_sessionTimeOut
&& (![timer isValid]
|| [_sessionTimeOut timeOutTime]<_timerFireTimeInterval
|| _timerFireTimeInterval<_now))
{
NSTimeInterval _timerTimeInterval=[_sessionTimeOut timeOutTime]-_now;
NSDebugMLLog(@"sessions",@"_timerTimeInterval=%ld",(long)_timerTimeInterval);
_timerTimeInterval=max(_timerTimeInterval,1);//20s minimum
NSDebugMLLog(@"sessions",@"_timerTimeInterval=%ld",(long)_timerTimeInterval);
_timerTimeInterval=max(_timerTimeInterval,10);//20s minimum
NSDebugMLLog(@"sessions",@"_timerTimeInterval=%ld",(long)_timerTimeInterval);
NSLog(@"new _timerTimeInterval=%ld",(long)_timerTimeInterval);
_newTimer=[NSTimer timerWithTimeInterval:_timerTimeInterval
target:self
selector:@selector(handleTimer:)
@ -330,4 +378,168 @@ static char rcsId[] = "$Id$";
LOGObjectFnStop();
};
@end
//====================================================================
@implementation GSWSessionTimeOutManager (GSWSessionRefused)
//--------------------------------------------------------------------
-(void)startHandleTimerRefusingSessions
{
NSTimer* _newTimer = nil;
NSLog(@"---Start startHandleTimerRefusingSessions");
//[GSWApplication statusLogWithFormat:@"Start startHandleTimerRefusingSessions"];
//LOGObjectFnStart();
[self lock];
/*
_newTimer=[NSTimer timerWithTimeInterval:5 // first time after 5 seconds
target:self
selector:@selector(handleTimerRefusingSessions:)
userInfo:nil
repeats:NO];
if (_newTimer) {
[GSWApp addTimer:_newTimer];
}
*/
_newTimer = [NSTimer scheduledTimerWithTimeInterval:5
target:self
selector:@selector(handleTimerRefusingSessions:)
userInfo:nil
repeats:NO];
[self unlock];
//LOGObjectFnStop();
//[GSWApplication statusLogWithFormat:@"Stop startHandleTimerRefusingSessions"];
NSLog(@"---Stop startHandleTimerRefusingSessions");
}
//--------------------------------------------------------------------
-(void)handleTimerKillingApplication:(id)timer_
{
NSLog(@"application is shutting down...");
[GSWApp lock];
[GSWApp lockRequestHandling];
[self lock];
[GSWApp dealloc];
[GSWApplication dealloc]; // call class method , not instance method
exit(0);
}
//--------------------------------------------------------------------
-(void)handleTimerRefusingSessions:(id)timer_
{
//OK
//NSLog(@"-Start HandleTimerRefusingSessions");
//[GSWApplication statusLogWithFormat:@"-Start HandleTimerRefusingSessions"];
//[GSWApp lockRequestHandling];
NS_DURING
{
[self lock];
NS_DURING
{
GSWApplication *ourApp = [GSWApplication application];
NSTimer *_timer=nil;
if (ourApp && [ourApp isRefusingNewSessions] && ([sessionOrderedTimeOuts count] <= [ourApp minimumActiveSessionsCount])) {
// okay , soft-shutdown for all avtive sessions
GSWSessionTimeOut *_sessionTimeOut=nil;
while ([sessionOrderedTimeOuts count] > 0) {
_sessionTimeOut = [sessionOrderedTimeOuts lastObject];
if (_sessionTimeOut) {
id _session=nil;
[target lock];
NS_DURING
{
_session=[target performSelector:callback
withObject:[_sessionTimeOut sessionID]];
NSDebugMLLog(@"sessions",@"_session=%@",_session);
}
NS_HANDLER
{
LOGException(@"%@ (%@)",localException,[localException reason]);
//TODO
[target unlock];
_timer = [NSTimer scheduledTimerWithTimeInterval:5
target:self
selector:@selector(handleTimerRefusingSessions:)
userInfo:nil
repeats:NO];
[self unlock];
//[GSWApp unlockRequestHandling];
[localException raise];
}
NS_ENDHANDLER;
[target unlock];
if (_session)
{
NSDebugMLLog(@"sessions",@"sessionOrderedTimeOuts=%@",sessionOrderedTimeOuts);
[_session terminate]; // ???
NSDebugMLLog(@"sessions",@"sessionOrderedTimeOuts=%@",sessionOrderedTimeOuts);
NSLog(@"GSWSessionTimeOutMananger : removeObject = %@", _sessionTimeOut);
[sessionOrderedTimeOuts removeObject:_sessionTimeOut];
[sessionTimeOuts removeObjectForKey:[_session sessionID]];
NSDebugMLLog(@"sessions",@"sessionOrderedTimeOuts=%@",sessionOrderedTimeOuts);
}
}
}
// app terminate
NSLog(@"application is preparing to shut down in 10 sec...");
_timer = [NSTimer scheduledTimerWithTimeInterval:10
target:self
selector:@selector(handleTimerKillingApplication:)
userInfo:nil
repeats:NO];
} else
{
// new timer, app does not terminate
_timer = [NSTimer scheduledTimerWithTimeInterval:5
target:self
selector:@selector(handleTimerRefusingSessions:)
userInfo:nil
repeats:NO];
}
}
NS_HANDLER
{
LOGException(@"%@ (%@)",localException,[localException reason]);
//TODO
[self unlock];
//[GSWApp unlockRequestHandling];
[localException raise];
};
NS_ENDHANDLER;
NSDebugMLLog(@"sessions",@"sessionOrderedTimeOuts=%@",sessionOrderedTimeOuts);
[self unlock];
}
NS_HANDLER
{
LOGException(@"%@ (%@)",localException,[localException reason]);
//TODO
//[GSWApp unlockRequestHandling];
[localException raise];
};
NS_ENDHANDLER;
//[GSWApp unlockRequestHandling];
//[GSWApplication statusLogWithFormat:@"-Stop HandleTimerRefusingSessions"];
//NSLog(@"-Stop HandleTimerRefusingSessions");
};
@end