Skip to content

Commit

Permalink
Merge pull request #513 from jcberquist/avoid-per-request-lock
Browse files Browse the repository at this point in the history
Remove locking from framework one global controller retrieval. No issues detected in my production environment for the last 1+month
  • Loading branch information
sneiland authored May 17, 2020
2 parents 5dae0a4 + a75b9bf commit 9e4394d
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions framework/one.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -1831,18 +1831,21 @@ component {
var controllersSlash = variables.framework.controllersFolder & '/';
var controllersDot = variables.framework.controllersFolder & '.';
// per #310 we no longer cache the Application controller since it is new on each request
if ( !structKeyExists( cache.controllers, componentKey ) || section == variables.magicApplicationController ) {
if ( section == variables.magicApplicationController ) {
if ( hasDefaultBeanFactory() ) {
autowire( this, getDefaultBeanFactory() );
}
return this;
}
if ( !structKeyExists( cache.controllers, componentKey ) ) {
lock name="fw1_#application.applicationName#_#variables.framework.applicationKey#_#componentKey#" type="exclusive" timeout="30" {
if ( !structKeyExists( cache.controllers, componentKey ) || section == variables.magicApplicationController ) {
if ( !structKeyExists( cache.controllers, componentKey ) ) {
if ( hasSubsystemBeanFactory( subsystem ) && getSubsystemBeanFactory( subsystem ).containsBean( beanName ) ) {
cfc = getSubsystemBeanFactory( subsystem ).getBean( beanName );
} else if ( !usingSubsystems() && hasDefaultBeanFactory() && getDefaultBeanFactory().containsBean( beanName ) ) {
cfc = getDefaultBeanFactory().getBean( beanName );
} else {
if ( section == variables.magicApplicationController ) {
// treat this (Application.cfc) as a controller:
cfc = this;
} else if ( cachedFileExists( cfcFilePath( request.cfcbase ) & subsystemDir & controllersSlash & section & '.cfc' ) ) {
if ( cachedFileExists( cfcFilePath( request.cfcbase ) & subsystemDir & controllersSlash & section & '.cfc' ) ) {
// we call createObject() rather than new so we can control initialization:
if ( request.cfcbase == '' ) {
cfc = createObject( 'component', subsystemDot & controllersDot & section );
Expand Down

0 comments on commit 9e4394d

Please sign in to comment.