* GSWSessionStore.m/h: cleanup locking

* GSWComponentContent.m: fix bug #28910, reported by Sergey Golovin
* GSWServerSessionStore.m: remove logs



git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@30265 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
dwetzel 2010-04-30 17:59:49 +00:00
parent 35ef68a787
commit ed10fe1ac7
4 changed files with 73 additions and 198 deletions

View file

@ -35,9 +35,19 @@ RCS_ID("$Id$")
#include "GSWeb.h"
static Class GSWHTMLBareStringClass = Nil;
//====================================================================
@implementation GSWComponentContent
+ (void) initialize
{
if (self == [GSWComponentContent class])
{
GSWHTMLBareStringClass = [GSWHTMLBareString class];
}
}
//--------------------------------------------------------------------
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)aContext
@ -70,33 +80,33 @@ RCS_ID("$Id$")
-(GSWElement*)invokeActionForRequest:(GSWRequest*)request
inContext:(GSWContext*)aContext
{
//OK
GSWElement* element=nil;
GSWComponent* component=nil;
GSWComponent* parent=nil;
GSWElement* childTemplate=nil;
GSWDeclareDebugElementIDsCount(aContext);
GSWStartElement(aContext);
component=GSWContext_component(aContext);
childTemplate=[component _childTemplate];
parent=[component parent];
[aContext _setCurrentComponent:parent];
element=[childTemplate invokeActionForRequest:request
inContext:aContext];
NSAssert3(!element || [element isKindOfClass:[GSWElement class]],
@"childTemplate=%@ Element is a %@ not a GSWElement: %@",
childTemplate,
[element class],
element);
[aContext _setCurrentComponent:component];
if ([childTemplate class] != GSWHTMLBareStringClass) {
parent=[component parent];
[aContext _setCurrentComponent:parent];
element=[childTemplate invokeActionForRequest:request
inContext:aContext];
NSAssert3(!element || [element isKindOfClass:[GSWElement class]],
@"childTemplate=%@ Element is a %@ not a GSWElement: %@",
childTemplate,
[element class],
element);
[aContext _setCurrentComponent:component];
}
GSWStopElement(aContext);
GSWAssertDebugElementIDsCount(aContext);
return element;
};
}
//--------------------------------------------------------------------
-(void)takeValuesFromRequest:(GSWRequest*)request

View file

@ -106,22 +106,14 @@ RCS_ID("$Id$")
/** Should be Locked **/
-(GSWSession*)removeSessionWithID:(NSString*)aSessionID
{
//OK
GSWSession* session=nil;
LOGObjectFnStart();
NSDebugMLLog(@"sessions",@"aSessionID=%@",aSessionID);
NSDebugMLLog(@"sessions",@"_sessions=%@",_sessions);
session=[_sessions objectForKey:aSessionID];
NSDebugMLLog(@"sessions",@"session=%@",session);
RETAIN(session); //to avoid discarding it now
[_sessions removeObjectForKey:aSessionID];
NSDebugMLLog(@"sessions",@"_sessions=%@",_sessions);
AUTORELEASE(session); //discard it 'later'
LOGObjectFnStop();
return session;
};
}
@end

View file

@ -51,8 +51,8 @@
-(void)checkInSessionForContext:(GSWContext*)aContext;
-(void)_checkInSessionForContext:(GSWContext*)aContext;
-(void)unlock;
-(BOOL)tryLock;
-(void)lock;
@end
@ -61,25 +61,6 @@
@interface GSWSessionStore (GSWSessionStoreCreation)
+(GSWSessionStore*)serverSessionStore;
@end
/*
//====================================================================
@interface GSWSessionStore (GSWSessionStoreOldFn)
+(GSWSessionStore*)cookieSessionStoreWithDistributionDomain:(NSString*)aDomain
secure:(BOOL)flag;
+(GSWSessionStore*)pageSessionStore;
+(GSWSessionStore*)serverSessionStore;
-(GSWSession*)restoreSession;
-(void)saveSession:(GSWSession*)session;
@end
*/
/*
//====================================================================
@interface GSWSessionStore (GSWSessionStoreA)
-(BOOL)_isSessionIDCheckedOut:(NSString*)aSessionID;
@end
*/
//====================================================================
@interface GSWSessionStore (GSWSessionStoreB)
-(void)_validateAPI;

View file

@ -4,6 +4,7 @@
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999
Written by: David Wetzel <dave@turbocat.de>
$Revision$
$Date$
@ -148,176 +149,82 @@ RCS_ID("$Id$")
//--------------------------------------------------------------------
-(void)checkInSessionForContext:(GSWContext*)aContext
{
//OK
LOGObjectFnStart();
if ([self tryLock])
{
NS_DURING
{
[self _checkInSessionForContext:aContext];
}
NS_HANDLER
{
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,
@"In _checkInSessionForContext:");
LOGException(@"%@ (%@)",localException,[localException reason]);
[self unlock];
[localException raise];
}
NS_ENDHANDLER;
[self unlock];
};
LOGObjectFnStop();
};
SYNCHRONIZED(_lock) {
[self _checkInSessionForContext:aContext];
}
END_SYNCHRONIZED;
}
//--------------------------------------------------------------------
/** Should be Locked **/
-(void)_checkInSessionForContext:(GSWContext*)aContext
{
GSWSession* session=nil;
LOGObjectFnStart();
session=[aContext existingSession];
NSDebugMLLog(@"sessions",@"session=%@",session);
if (!session)
{
[NSException raise:@"IllegalStateException"
format:@"Current context has no existing session. Can't save session"];
}
{
[NSException raise:@"IllegalStateException"
format:@"Current context has no existing session. Can't save session"];
}
else
{
NS_DURING
{
NSString* sessionID=nil;
BOOL sessionIsTerminating=NO;
NSTimeInterval sessionTimeOut=0;
GSWSessionTimeOut* entry=nil;
[session retain];
sessionID=[session sessionID];
NSAssert(sessionID,@"No _sessionID!");
NSDebugMLLog(@"sessions",@"_sessionID=%@",sessionID);
GSWLogAssertGood(session);
sessionIsTerminating=[session isTerminating];
[session setDistributionEnabled:sessionIsTerminating];
entry=[_timeOutManager sessionTimeOutForSessionID:sessionID];
[entry setIsCheckedOut:NO];
if (sessionIsTerminating)
{
NS_DURING
{
[self removeSessionWithID:sessionID];
}
NS_HANDLER
{
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,
@"In removeSessionWithID:");
NSLog(@"### exception ... %@", [localException reason]);
LOGException(@"%@ (%@)",localException,[localException reason]);
[localException raise];
}
NS_ENDHANDLER;
}
else
{
NS_DURING
{
[self saveSessionForContext:aContext];
}
NS_HANDLER
{
NSLog(@"### exception ... %@", [localException reason]);
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,
@"In saveSessionForContext:");
LOGException(@"%@ (%@)",localException,[localException reason]);
[localException raise];
}
NS_ENDHANDLER;
};
{
[self removeSessionWithID:sessionID];
} else {
[self saveSessionForContext:aContext];
}
sessionTimeOut=[session timeOut];
NSDebugMLLog(@"sessions",@"sessionTimeOut=%ld",(long)sessionTimeOut);
[_timeOutManager updateTimeOutForSessionWithID:sessionID
timeOut:sessionTimeOut];
// why do we do that?
//[session _releaseAutoreleasePool];
NS_DURING
{
[_timeOutManager updateTimeOutForSessionWithID:sessionID
timeOut:sessionTimeOut];
}
NS_HANDLER
{
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,
@"In _checkinSessionID");
LOGException(@"%@ (%@)",localException,[localException reason]);
[localException raise];
}
NS_ENDHANDLER;
GSWLogAssertGood(session);
NSDebugMLLog(@"sessions",@"session=%@",session);
NS_DURING
{
[session _releaseAutoreleasePool];
}
NS_HANDLER
{
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,
@"In [_session _releaseAutoreleasePool]");
LOGException(@"%@ (%@)",localException,[localException reason]);
[localException raise];
}
NS_ENDHANDLER;
GSWLogAssertGood(session);
NSDebugMLLog(@"sessions",@"session=%@",session);
sessionID=[session sessionID];
GSWLogAssertGood(session);
NSDebugMLLog(@"sessions",@"sessionID=%@",sessionID);
};
LOGObjectFnStop();
};
[session release];
session = nil;
} NS_HANDLER {
[session release];
session = nil;
[localException raise];
} NS_ENDHANDLER;
}
}
//--------------------------------------------------------------------
-(void)unlock
{
LOGObjectFnStart();
NSDebugMLLog(@"sessions",@"lockn=%d",_lockn);
LoggedUnlock(_lock);
#ifndef NDEBUG
_lockn--;
#endif
NSDebugMLLog(@"sessions",@"lockn=%d",_lockn);
LOGObjectFnStop();
};
//--------------------------------------------------------------------
-(BOOL)tryLock
{
BOOL locked=NO;
LOGObjectFnStart();
NSDebugMLLog(@"sessions",@"lockn=%d",_lockn);
locked=LoggedTryLockBeforeDate(_lock,GSW_LOCK_LIMIT);
#ifndef NDEBUG
if (locked)
_lockn++;
#endif
NSDebugMLLog(@"sessions",@"lockn=%d",_lockn);
LOGObjectFnStop();
return locked;
};
[_lock unlock];
}
//--------------------------------------------------------------------
-(void)lock
{
LOGObjectFnStart();
NSDebugMLLog(@"sessions",@"lockn=%d",_lockn);
LoggedLockBeforeDate(_lock,GSW_LOCK_LIMIT);
#ifndef NDEBUG
_lockn++;
#endif
NSDebugMLLog(@"sessions",@"lockn=%d",_lockn);
LOGObjectFnStop();
};
[_lock lock];
}
@end
@ -372,21 +279,6 @@ RCS_ID("$Id$")
};
@end
/*
//====================================================================
@implementation GSWSessionStore (GSWSessionStoreA)
-(BOOL)_isSessionIDCheckedOut:(NSString*)aSessionID
{
//OK
BOOL checkedOut=NO;
LOGObjectFnStart();
checkedOut=[_usedIDs containsObject:aSessionID];
LOGObjectFnStop();
return checkedOut;
};
@end
*/
//====================================================================
@implementation GSWSessionStore (GSWSessionStoreB)
-(void)_validateAPI