Patch level : 10.0 0044
Files correlati : Postman Ricompilazione Demo : [ ] Commento : Aggiunto Multithread dei poveri git-svn-id: svn://10.65.10.50/trunk@16562 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
7313a0f4e8
commit
7f0c7a2cbf
@ -157,6 +157,7 @@ enum
|
|||||||
BEGIN_EVENT_TABLE(TBaseServerApp, wxApp)
|
BEGIN_EVENT_TABLE(TBaseServerApp, wxApp)
|
||||||
EVT_SOCKET(SERVER_ID, TBaseServerApp::OnServerEvent)
|
EVT_SOCKET(SERVER_ID, TBaseServerApp::OnServerEvent)
|
||||||
EVT_SOCKET(SOCKET_ID, TBaseServerApp::OnSocketEvent)
|
EVT_SOCKET(SOCKET_ID, TBaseServerApp::OnSocketEvent)
|
||||||
|
EVT_IDLE(TBaseServerApp::OnIdle)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
void TBaseServerApp::WriteLog(const wxChar* str) const
|
void TBaseServerApp::WriteLog(const wxChar* str) const
|
||||||
@ -476,10 +477,8 @@ void TBaseServerApp::OnServerEvent(wxSocketEvent& e)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
WriteLog("### Error: couldn't accept a new connection");
|
WriteLog("### Error: couldn't accept a new connection");
|
||||||
sock->Destroy();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sock->SetEventHandler(*this, SOCKET_ID);
|
sock->SetEventHandler(*this, SOCKET_ID);
|
||||||
sock->SetNotify(wxSOCKET_INPUT_FLAG | wxSOCKET_LOST_FLAG);
|
sock->SetNotify(wxSOCKET_INPUT_FLAG | wxSOCKET_LOST_FLAG);
|
||||||
sock->Notify(TRUE);
|
sock->Notify(TRUE);
|
||||||
@ -494,43 +493,56 @@ void TBaseServerApp::OnSocketEvent(wxSocketEvent& e)
|
|||||||
{
|
{
|
||||||
// We disable input events, so that the test doesn't trigger
|
// We disable input events, so that the test doesn't trigger
|
||||||
// wxSocketEvent again.
|
// wxSocketEvent again.
|
||||||
sock.SetNotify(wxSOCKET_LOST_FLAG);
|
m_Sockets.Add(&sock);
|
||||||
|
|
||||||
// Read the data
|
|
||||||
const size_t BUFSIZE = 1024;
|
|
||||||
wxString str;
|
|
||||||
wxChar buf[BUFSIZE + 1];
|
|
||||||
|
|
||||||
memset(buf, 0, sizeof(buf));
|
|
||||||
while (sock.Read(buf, BUFSIZE).LastCount() == BUFSIZE)
|
|
||||||
{
|
|
||||||
str << buf;
|
|
||||||
memset(buf, 0, sizeof(buf));
|
|
||||||
}
|
|
||||||
|
|
||||||
str << buf;
|
|
||||||
WriteLog(str);
|
|
||||||
|
|
||||||
if (CanProcessCommand(str, sock))
|
|
||||||
{
|
|
||||||
const wxSocketFlags flags = sock.GetFlags();
|
|
||||||
sock.SetFlags(wxSOCKET_WAITALL);
|
|
||||||
ProcessCommand(str, sock);
|
|
||||||
sock.SetFlags(flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enable input events again.
|
|
||||||
sock.SetNotify(wxSOCKET_LOST_FLAG | wxSOCKET_INPUT_FLAG);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case wxSOCKET_LOST:
|
case wxSOCKET_LOST:
|
||||||
WriteLog("--- Deleting socket.");
|
WriteLog("--- Deleting socket.");
|
||||||
|
if (m_Sockets.Index(&sock) >= 0)
|
||||||
|
m_Sockets.Remove(&sock);
|
||||||
sock.Destroy();
|
sock.Destroy();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void TBaseServerApp::OnIdle(wxIdleEvent& event)
|
||||||
|
{
|
||||||
|
if (m_Sockets.GetCount() > 0)
|
||||||
|
{
|
||||||
|
wxSocketBase& sock = *(wxSocketBase *) m_Sockets[0];
|
||||||
|
|
||||||
|
sock.SetNotify(wxSOCKET_LOST_FLAG);
|
||||||
|
|
||||||
|
// Read the data
|
||||||
|
const size_t BUFSIZE = 1024;
|
||||||
|
wxString str;
|
||||||
|
wxChar buf[BUFSIZE + 1];
|
||||||
|
|
||||||
|
memset(buf, 0, sizeof(buf));
|
||||||
|
while (sock.Read(buf, BUFSIZE).LastCount() == BUFSIZE)
|
||||||
|
{
|
||||||
|
str << buf;
|
||||||
|
memset(buf, 0, sizeof(buf));
|
||||||
|
}
|
||||||
|
|
||||||
|
str << buf;
|
||||||
|
WriteLog(str);
|
||||||
|
|
||||||
|
if (CanProcessCommand(str, sock))
|
||||||
|
{
|
||||||
|
const wxSocketFlags flags = sock.GetFlags();
|
||||||
|
sock.SetFlags(wxSOCKET_WAITALL);
|
||||||
|
ProcessCommand(str, sock);
|
||||||
|
sock.SetFlags(flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enable input events again.
|
||||||
|
sock.SetNotify(wxSOCKET_LOST_FLAG | wxSOCKET_INPUT_FLAG);
|
||||||
|
m_Sockets.Remove(&sock);
|
||||||
|
}
|
||||||
|
wxApp::OnIdle(event);
|
||||||
|
}
|
||||||
|
|
||||||
const wxString& TBaseServerApp::GetConfigName() const
|
const wxString& TBaseServerApp::GetConfigName() const
|
||||||
{
|
{
|
||||||
|
@ -85,6 +85,7 @@ private:
|
|||||||
wxString m_strPath, m_strTempDir, m_strIni;
|
wxString m_strPath, m_strTempDir, m_strIni;
|
||||||
bool m_bRunning;
|
bool m_bRunning;
|
||||||
int m_nTmpCounter;
|
int m_nTmpCounter;
|
||||||
|
wxArrayPtrVoid m_Sockets;
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
TTaskBarIcon* m_Tray;
|
TTaskBarIcon* m_Tray;
|
||||||
@ -143,6 +144,7 @@ public:
|
|||||||
virtual int OnExit();
|
virtual int OnExit();
|
||||||
void OnServerEvent(wxSocketEvent& event);
|
void OnServerEvent(wxSocketEvent& event);
|
||||||
void OnSocketEvent(wxSocketEvent& event);
|
void OnSocketEvent(wxSocketEvent& event);
|
||||||
|
void OnIdle(wxIdleEvent& event);
|
||||||
DECLARE_EVENT_TABLE();
|
DECLARE_EVENT_TABLE();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -314,7 +314,7 @@ bool TPostmanServer::LoadEditors(const wxChar * filename, wxArrayString & editor
|
|||||||
|
|
||||||
int TPostmanServer::GetDefaultPort() const
|
int TPostmanServer::GetDefaultPort() const
|
||||||
{
|
{
|
||||||
return GetConfigInt("Port", 80);
|
return GetConfigInt("Port", 8080);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPostmanServer::SaveXml2IniParagraph(wxFileConfig& ini, TXmlItem& xmlItem)
|
void TPostmanServer::SaveXml2IniParagraph(wxFileConfig& ini, TXmlItem& xmlItem)
|
||||||
@ -412,17 +412,19 @@ void TPostmanServer::ExecuteTransaction(wxString & filename)
|
|||||||
wxString editor(EditorCommand());
|
wxString editor(EditorCommand());
|
||||||
if (!editor.IsEmpty())
|
if (!editor.IsEmpty())
|
||||||
{
|
{
|
||||||
wxString str;
|
wxFileName cmdname(editor);
|
||||||
|
|
||||||
str << "../" << editor;
|
if (cmdname.IsRelative())
|
||||||
|
{
|
||||||
wxFileName cmdname(str);
|
cmdname.MakeAbsolute();
|
||||||
|
cmdname.RemoveLastDir();
|
||||||
cmdname.MakeAbsolute();
|
}
|
||||||
|
|
||||||
wxString command(cmdname.GetFullPath());
|
wxString command(cmdname.GetFullPath());
|
||||||
|
|
||||||
const wxString currdir(wxGetCwd());
|
const wxString currdir(wxGetCwd());
|
||||||
wxSetWorkingDirectory("../");
|
|
||||||
|
wxSetWorkingDirectory(cmdname.GetPath());
|
||||||
command << " -i" <<filename << " -uADMIN";
|
command << " -i" <<filename << " -uADMIN";
|
||||||
m_Err = 0;
|
m_Err = 0;
|
||||||
if (::wxExecute(command, wxEXEC_SYNC) < 0)
|
if (::wxExecute(command, wxEXEC_SYNC) < 0)
|
||||||
@ -461,7 +463,8 @@ void TPostmanServer::LoadXmlParagraph(TXmlItem& xmlItem, wxString& paragraph, wx
|
|||||||
if (logicnum > 0)
|
if (logicnum > 0)
|
||||||
{
|
{
|
||||||
child.SetAttr("LogicNumber", logicnum);
|
child.SetAttr("LogicNumber", logicnum);
|
||||||
child.SetAttr("TableName", m_TableName[logicnum]);
|
if (logicnum < m_TableName.GetCount())
|
||||||
|
child.SetAttr("TableName", m_TableName[logicnum]);
|
||||||
|
|
||||||
if (rownum > 0)
|
if (rownum > 0)
|
||||||
child.SetAttr("RowNumber", rownum);
|
child.SetAttr("RowNumber", rownum);
|
||||||
@ -551,6 +554,7 @@ void TPostmanServer::SoapProcessMethod(const TXmlItem& xmlMethod, TXmlItem& xmlA
|
|||||||
ExecuteTransaction(name);
|
ExecuteTransaction(name);
|
||||||
LoadTransaction(name, xmlAnswer);
|
LoadTransaction(name, xmlAnswer);
|
||||||
Log(xmlAnswer, name);
|
Log(xmlAnswer, name);
|
||||||
|
wxRemoveFile(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user