Patch level : 10.0

Files correlati     : lurch.exe
Ricompilazione Demo : [ ]
Commento            :
Migliorata gestione restart di Authorization


git-svn-id: svn://10.65.10.50/branches/R_10_00@22315 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2011-06-23 15:54:48 +00:00
parent 0449fed52d
commit 8a39e3f976

View File

@ -36,7 +36,7 @@ protected:
const TProcessHashMap& GetRunningServers() const { return m_hmProcMap; } const TProcessHashMap& GetRunningServers() const { return m_hmProcMap; }
bool PingProcess(const wxString& strApp); bool PingProcess(const wxString& strApp);
void StopProcess(const wxString& strApp); bool StopProcess(const wxString& strApp);
wxString StartProcess(const wxString& strApp); wxString StartProcess(const wxString& strApp);
TXmlItem& AddTableRow(TXmlItem& table, const wxChar* prompt, const wxString& value) const; TXmlItem& AddTableRow(TXmlItem& table, const wxChar* prompt, const wxString& value) const;
@ -168,13 +168,13 @@ void TLurchServer::OnTimer(wxTimerEvent& evt)
void TLurchServer::OnEndProcess(wxProcessEvent& evt) void TLurchServer::OnEndProcess(wxProcessEvent& evt)
{ {
TProcessHashMap::const_iterator it; for (TProcessHashMap::const_iterator it = m_hmProcMap.begin(); it != m_hmProcMap.end(); ++it)
for (it = m_hmProcMap.begin(); it != m_hmProcMap.end(); ++it)
{ {
const wxProcess* p = it->second; const wxProcess* p = it->second;
if (p->GetPid() == evt.GetPid()) if (p->GetPid() == evt.GetPid())
{ {
ForgetProcess(it->first); const wxString name = it->first;
ForgetProcess(name);
break; break;
} }
} }
@ -290,7 +290,7 @@ void TLurchServer::GenerateFile(wxString& strFilename)
const bool bAutoRun = bLurch || GetAutoRunList().Index(arr[i]) != wxNOT_FOUND; const bool bAutoRun = bLurch || GetAutoRunList().Index(arr[i]) != wxNOT_FOUND;
TXmlItem& buttStart = AddMiniForm(tr, "start.cgi", arr[i], _("Start")); TXmlItem& buttStart = AddMiniForm(tr, "start.cgi", arr[i], _("Start"));
if (bRunning || bAutoRun) if (bRunning /* || bAutoRun */)
buttStart.SetAttr(wxT("type"), wxT("hidden")); buttStart.SetAttr(wxT("type"), wxT("hidden"));
TXmlItem& buttStop = AddMiniForm(tr, "kill.cgi", arr[i], _("Stop")); TXmlItem& buttStop = AddMiniForm(tr, "kill.cgi", arr[i], _("Stop"));
@ -422,12 +422,23 @@ void TLurchServer::ProcessFormStart(const THashTable& args, wxSocketBase& sock)
bool TLurchServer::ForgetProcess(const wxString& strApp) bool TLurchServer::ForgetProcess(const wxString& strApp)
{ {
WriteLog(strApp + _(" terminated.")); bool ok = m_hmProcMap.erase(strApp) != 0;
return m_hmProcMap.erase(strApp) != 0; if (ok)
WriteLog(strApp + _(" terminated."));
return ok;
} }
void TLurchServer::StopProcess(const wxString& strApp) bool TLurchServer::StopProcess(const wxString& strApp)
{ {
if (strApp != GetAppName())
{
const wxSingleInstanceChecker sic(strApp);
if (!sic.IsAnotherRunning()) // E' belle che muorto!
return ForgetProcess(strApp);
}
else
return false;
const wxString strHost = GetConfigString("Host", "localhost", strApp); const wxString strHost = GetConfigString("Host", "localhost", strApp);
const int nPort = GetConfigInt("Port", 0, strApp); const int nPort = GetConfigInt("Port", 0, strApp);
if (nPort > 0) if (nPort > 0)
@ -455,12 +466,13 @@ void TLurchServer::StopProcess(const wxString& strApp)
if (p != NULL) if (p != NULL)
{ {
p->Kill(p->GetPid()); p->Kill(p->GetPid());
ForgetProcess(strApp); return ForgetProcess(strApp);
} }
} }
} }
} }
} }
return false;
} }
void TLurchServer::ProcessFormStop(const THashTable& args, wxSocketBase& sock) void TLurchServer::ProcessFormStop(const THashTable& args, wxSocketBase& sock)
@ -670,13 +682,11 @@ bool TLurchServer::Initialization()
{ {
for (size_t i = 0; i < nAuto; i++) for (size_t i = 0; i < nAuto; i++)
StartProcess(arr[i]); StartProcess(arr[i]);
const int nFreq = GetConfigInt("PingFreq"); const int nFreq = GetConfigInt("PingFreq");
if (nFreq > 0) if (nFreq > 0)
{ m_PingTimer.Start(nFreq * 1000); // sec to msec
m_PingTimer.Start(nFreq * 1000); // sec to msec
m_Semaphore.Post(); // GREEN!
}
} }
m_Semaphore.Post(); // GREEN!
return true; return true;
} }