mirror of
https://github.com/gnustep/libs-gsweb.git
synced 2025-02-21 02:41:04 +00:00
small cosmetic changes in spacing.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@24214 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
2f2a13fc47
commit
126006dd58
1 changed files with 137 additions and 137 deletions
|
@ -71,80 +71,81 @@ GSWLoadBalancing_FindApp(GSWAppRequest *p_pAppRequest,
|
|||
GSWAppInstance *pAppInstance=NULL;
|
||||
time_t curTime = (time_t)0;
|
||||
|
||||
while (!fFound && iTries-->0)
|
||||
{
|
||||
pApp->iLastInstanceIndex = (pApp->iLastInstanceIndex+1) % uInstancesCount;
|
||||
GSWDebugLog(p_pLogServerData,"LoadBalancing: Will try instance %d (instances count=%d).",
|
||||
pApp->iLastInstanceIndex,uInstancesCount);
|
||||
pAppInstance =
|
||||
(GSWAppInstance *)GSWDict_ValueForKey(&pApp->stInstancesDict,
|
||||
GSWList_ElementAtIndex(pInstancesList,
|
||||
pApp->iLastInstanceIndex));
|
||||
if (pAppInstance)
|
||||
{
|
||||
if (!pAppInstance->pApp)
|
||||
{
|
||||
GSWLog(GSW_CRITICAL,p_pLogServerData,
|
||||
"AppInstance pApp is null pAppInstance=%p",
|
||||
pAppInstance);
|
||||
};
|
||||
if (pAppInstance->timeNextRetryTime!=0)
|
||||
{
|
||||
if (!curTime)
|
||||
time(&curTime);
|
||||
if (pAppInstance->timeNextRetryTime<curTime)
|
||||
{
|
||||
GSWLog(GSW_WARNING,
|
||||
p_pLogServerData,
|
||||
"LoadBalance: Instance %s:%d was marked dead for %d secs. Now resurecting !",
|
||||
p_pAppRequest->pszName,
|
||||
pAppInstance->iInstance,
|
||||
APP_CONNECT_RETRY_DELAY);
|
||||
pAppInstance->timeNextRetryTime=0;
|
||||
};
|
||||
};
|
||||
if (pAppInstance->timeNextRetryTime==0 && pAppInstance->fValid)
|
||||
{
|
||||
BOOL okay = TRUE;
|
||||
// check if refused, time to try again ?
|
||||
if (p_pURLComponents->stRequestHandlerKey.iLength==0 ||
|
||||
p_pURLComponents->stRequestHandlerKey.pszStart==NULL)
|
||||
{
|
||||
GSWAppInfo *thisAppInfo =
|
||||
GSWAppInfo_Find(p_pAppRequest->pszName,
|
||||
pAppInstance->iInstance);
|
||||
if (thisAppInfo && thisAppInfo->isRefused)
|
||||
{
|
||||
time_t actTime = (time_t)0;
|
||||
// this instance refuses new sessions
|
||||
time(&actTime);
|
||||
if (actTime > thisAppInfo->timeNextRetryTime)
|
||||
{
|
||||
thisAppInfo->isRefused = FALSE; // try it again
|
||||
}
|
||||
else
|
||||
{
|
||||
okay = FALSE; // try an other instance
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (okay == TRUE)
|
||||
{
|
||||
fFound = TRUE;
|
||||
strcpy(p_pAppRequest->pszName,pApp->pszName);
|
||||
p_pAppRequest->iInstance = pAppInstance->iInstance;
|
||||
p_pAppRequest->pszHost = pAppInstance->pszHostName;
|
||||
p_pAppRequest->iPort = pAppInstance->iPort;
|
||||
p_pAppRequest->eType = EAppType_LoadBalanced;
|
||||
p_pAppRequest->pAppInstance = pAppInstance;
|
||||
pAppInstance->uOpenedRequestsNb++;
|
||||
}
|
||||
};
|
||||
};
|
||||
};
|
||||
while (!fFound && ((iTries--) > 0))
|
||||
{
|
||||
pApp->iLastInstanceIndex = (pApp->iLastInstanceIndex+1) % uInstancesCount;
|
||||
GSWDebugLog(p_pLogServerData,"LoadBalancing: Will try instance %d (instances count=%d).",
|
||||
pApp->iLastInstanceIndex,uInstancesCount);
|
||||
pAppInstance =
|
||||
(GSWAppInstance *)GSWDict_ValueForKey(&pApp->stInstancesDict,
|
||||
GSWList_ElementAtIndex(pInstancesList,
|
||||
pApp->iLastInstanceIndex));
|
||||
if (pAppInstance)
|
||||
{
|
||||
if (!pAppInstance->pApp)
|
||||
{
|
||||
GSWLog(GSW_CRITICAL,p_pLogServerData,
|
||||
"AppInstance pApp is null pAppInstance=%p",
|
||||
pAppInstance);
|
||||
};
|
||||
if (pAppInstance->timeNextRetryTime!=0)
|
||||
{
|
||||
if (!curTime)
|
||||
time(&curTime);
|
||||
if (pAppInstance->timeNextRetryTime<curTime)
|
||||
{
|
||||
GSWLog(GSW_WARNING,
|
||||
p_pLogServerData,
|
||||
"LoadBalance: Instance %s:%d was marked dead for %d secs. Now resurecting !",
|
||||
p_pAppRequest->pszName,
|
||||
pAppInstance->iInstance,
|
||||
APP_CONNECT_RETRY_DELAY);
|
||||
pAppInstance->timeNextRetryTime=0;
|
||||
};
|
||||
};
|
||||
|
||||
if (pAppInstance->timeNextRetryTime==0 && pAppInstance->fValid)
|
||||
{
|
||||
BOOL okay = TRUE;
|
||||
// check if refused, time to try again ?
|
||||
if (p_pURLComponents->stRequestHandlerKey.iLength==0 ||
|
||||
p_pURLComponents->stRequestHandlerKey.pszStart==NULL)
|
||||
{
|
||||
GSWAppInfo *thisAppInfo =
|
||||
GSWAppInfo_Find(p_pAppRequest->pszName,
|
||||
pAppInstance->iInstance);
|
||||
if (thisAppInfo && thisAppInfo->isRefused)
|
||||
{
|
||||
time_t actTime = (time_t)0;
|
||||
// this instance refuses new sessions
|
||||
time(&actTime);
|
||||
if (actTime > thisAppInfo->timeNextRetryTime)
|
||||
{
|
||||
thisAppInfo->isRefused = FALSE; // try it again
|
||||
}
|
||||
else
|
||||
{
|
||||
okay = FALSE; // try an other instance
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (okay == TRUE)
|
||||
{
|
||||
fFound = TRUE;
|
||||
strcpy(p_pAppRequest->pszName,pApp->pszName);
|
||||
p_pAppRequest->iInstance = pAppInstance->iInstance;
|
||||
p_pAppRequest->pszHost = pAppInstance->pszHostName;
|
||||
p_pAppRequest->iPort = pAppInstance->iPort;
|
||||
p_pAppRequest->eType = EAppType_LoadBalanced;
|
||||
p_pAppRequest->pAppInstance = pAppInstance;
|
||||
pAppInstance->uOpenedRequestsNb++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
GSWList_Free(pInstancesList,FALSE);
|
||||
};
|
||||
}
|
||||
GSWLock_Unlock(g_lockAppList);
|
||||
|
||||
if (fFound)
|
||||
|
@ -181,77 +182,76 @@ GSWLoadBalancing_FindInstance(GSWAppRequest *p_pAppRequest,
|
|||
|
||||
pApp = (GSWApp *)GSWConfig_GetApp(p_pAppRequest->pszName);
|
||||
if (pApp)
|
||||
{
|
||||
GSWAppInstance *pAppInstance=NULL;
|
||||
char szInstanceNum[50]="";
|
||||
sprintf(szInstanceNum,"%d",p_pAppRequest->iInstance);
|
||||
pAppInstance =
|
||||
(GSWAppInstance *)GSWDict_ValueForKey(&pApp->stInstancesDict,
|
||||
szInstanceNum);
|
||||
{
|
||||
GSWAppInstance *pAppInstance = NULL;
|
||||
char szInstanceNum[50] = "";
|
||||
|
||||
// Not a known instance
|
||||
if (!pAppInstance)
|
||||
{
|
||||
// but we can switch to a known one ?
|
||||
if (pApp->fSwitchToKnownInstance)
|
||||
fFound=GSWLoadBalancing_FindApp(p_pAppRequest,
|
||||
p_pLogServerData,
|
||||
p_pURLComponents);
|
||||
}
|
||||
else
|
||||
{
|
||||
GSWDebugLog(p_pLogServerData,"Instance Found");
|
||||
if (pAppInstance->fValid)
|
||||
{
|
||||
BOOL okay = TRUE;
|
||||
// check if refused, time to try again ?
|
||||
if (p_pURLComponents->stRequestHandlerKey.iLength==0 ||
|
||||
p_pURLComponents->stRequestHandlerKey.pszStart==NULL)
|
||||
{
|
||||
GSWAppInfo *thisAppInfo =
|
||||
GSWAppInfo_Find(p_pAppRequest->pszName,
|
||||
pAppInstance->iInstance);
|
||||
if (thisAppInfo && thisAppInfo->isRefused)
|
||||
{
|
||||
time_t actTime = (time_t)0;
|
||||
// this instance refuses new sessions
|
||||
time(&actTime);
|
||||
if (actTime > thisAppInfo->timeNextRetryTime)
|
||||
{
|
||||
thisAppInfo->isRefused = FALSE; // try it again
|
||||
}
|
||||
else
|
||||
{
|
||||
okay = FALSE; // try an other instance
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (okay == TRUE)
|
||||
{
|
||||
fFound=TRUE;
|
||||
p_pAppRequest->iInstance = pAppInstance->iInstance;
|
||||
p_pAppRequest->pszHost = pAppInstance->pszHostName;
|
||||
p_pAppRequest->iPort = pAppInstance->iPort;
|
||||
p_pAppRequest->eType = EAppType_LoadBalanced;
|
||||
p_pAppRequest->pAppInstance = pAppInstance;
|
||||
pAppInstance->uOpenedRequestsNb++;
|
||||
GSWDebugLog(p_pLogServerData,"Instance is valid");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GSWDebugLog(p_pLogServerData,"Instance is not valid");
|
||||
};
|
||||
};
|
||||
};
|
||||
sprintf(szInstanceNum,"%d",p_pAppRequest->iInstance);
|
||||
|
||||
pAppInstance = (GSWAppInstance *)GSWDict_ValueForKey(&pApp->stInstancesDict,
|
||||
szInstanceNum);
|
||||
|
||||
// Not a known instance
|
||||
if (!pAppInstance)
|
||||
{
|
||||
// but we can switch to a known one ?
|
||||
if (pApp->fSwitchToKnownInstance)
|
||||
fFound=GSWLoadBalancing_FindApp(p_pAppRequest,
|
||||
p_pLogServerData,
|
||||
p_pURLComponents);
|
||||
} else {
|
||||
|
||||
GSWDebugLog(p_pLogServerData,"Instance Found");
|
||||
if (pAppInstance->fValid)
|
||||
{
|
||||
BOOL okay = TRUE;
|
||||
// check if refused, time to try again ?
|
||||
if (p_pURLComponents->stRequestHandlerKey.iLength==0 || p_pURLComponents->stRequestHandlerKey.pszStart==NULL)
|
||||
{
|
||||
GSWAppInfo *thisAppInfo =
|
||||
GSWAppInfo_Find(p_pAppRequest->pszName,
|
||||
pAppInstance->iInstance);
|
||||
|
||||
if (thisAppInfo && thisAppInfo->isRefused)
|
||||
{
|
||||
time_t actTime = (time_t)0;
|
||||
// this instance refuses new sessions
|
||||
time(&actTime);
|
||||
|
||||
if (actTime > thisAppInfo->timeNextRetryTime)
|
||||
{
|
||||
thisAppInfo->isRefused = FALSE; // try it again
|
||||
}
|
||||
else
|
||||
{
|
||||
okay = FALSE; // try an other instance
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (okay == TRUE)
|
||||
{
|
||||
fFound=TRUE;
|
||||
p_pAppRequest->iInstance = pAppInstance->iInstance;
|
||||
p_pAppRequest->pszHost = pAppInstance->pszHostName;
|
||||
p_pAppRequest->iPort = pAppInstance->iPort;
|
||||
p_pAppRequest->eType = EAppType_LoadBalanced;
|
||||
p_pAppRequest->pAppInstance = pAppInstance;
|
||||
pAppInstance->uOpenedRequestsNb++;
|
||||
GSWDebugLog(p_pLogServerData,"Instance is valid");
|
||||
}
|
||||
} else {
|
||||
GSWDebugLog(p_pLogServerData,"Instance is not valid");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GSWLock_Unlock(g_lockAppList);
|
||||
|
||||
GSWDebugLog(p_pLogServerData,"Stop GSWLoadBalancing_FindInstance");
|
||||
|
||||
return fFound;
|
||||
};
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void
|
||||
|
|
Loading…
Reference in a new issue