Commit 88ef7bcd authored by Oleg.Korshul's avatar Oleg.Korshul Committed by Alexander Trofimov

проблема с параллельным запуском под линукс

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@64248 954022d7-b5bf-4e40-9824-e11837661b57
parent 316d8acd
...@@ -251,34 +251,21 @@ int CHtmlFile::Convert(const std::vector<std::wstring>& arFiles, const std::wstr ...@@ -251,34 +251,21 @@ int CHtmlFile::Convert(const std::vector<std::wstring>& arFiles, const std::wstr
(char * const *)nenv); (char * const *)nenv);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
#else #else
const char* nargs[4];
nargs[0] = "--auto-servernum"; const char* nargs[6];
nargs[1] = sProgramm.c_str(); nargs[0] = "-a";
nargs[2] = sXmlA.c_str(); nargs[1] = "--auto-servernum";
nargs[3] = NULL; nargs[2] = "--server-num=1";
nargs[3] = sProgramm.c_str();
nargs[4] = sXmlA.c_str();
nargs[5] = NULL;
const char* nenv[3]; const char* nenv[3];
nenv[0] = sLibraryDir.c_str(); nenv[0] = sLibraryDir.c_str();
nenv[1] = "DISPLAY=:99"; nenv[1] = NULL;//"DISPLAY=:99";
nenv[2] = NULL; nenv[2] = NULL;
execve("/usr/bin/xvfb-run", (char * const *)nargs, (char * const *)nenv); execve("/usr/bin/xvfb-run", (char * const *)nargs, (char * const *)nenv);
/*
std::string ssXml = "\"" + sXmlA + "\"";
int nRes = execl("/usr/bin/Xvfb", "X", ":4");
execl("/usr/bin/xvfb-run",
"-a",
"/home/oleg/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents/HtmlFile/Internal/linux/Release/HtmlFileInternal",
ssXml.c_str());
FILE* f = fopen("/home/oleg/activex/1/111.log", "a+");
fprintf(f, "ececl: %d\n", (int)errno);
fclose(f);
*/
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
#endif #endif
break; break;
......
#include "../HtmlFile.h" #include "../HtmlFile.h"
#include "../../DesktopEditor/common/File.h" #include "../../DesktopEditor/common/File.h"
#include "../../DesktopEditor/graphics/BaseThread.h"
#include "../../DesktopEditor/graphics/TemporaryCS.h"
class CCounter
{
private:
NSCriticalSection::CRITICAL_SECTION m_oCS;
int m_lCounter;
public:
CCounter()
{
m_oCS.InitializeCriticalSection();
m_lCounter = 0;
}
~CCounter()
{
m_oCS.DeleteCriticalSection();
}
public:
void Increment(int nCount = 1)
{
CTemporaryCS oCS(&m_oCS);
m_lCounter += nCount;
}
void Decrement()
{
CTemporaryCS oCS(&m_oCS);
--m_lCounter;
}
int GetCounter()
{
CTemporaryCS oCS(&m_oCS);
return m_lCounter;
}
};
class CThreadConverter : public NSThreads::CBaseThread
{
public:
CCounter* m_pCounter;
int m_nDstId;
public:
CThreadConverter() : NSThreads::CBaseThread()
{
m_pCounter = NULL;
m_nDstId = 1;
}
void SetCounter(CCounter* pCounter)
{
m_pCounter = pCounter;
}
protected:
DWORD ThreadProc()
{
std::wstring sPath = NSFile::GetProcessDirectory() + L"/../../Internal/linux/Release/";
std::wstring sSrc = L"/home/oleg/activex/37898EB";
std::wstring sDstFolder = L"/home/oleg/activex/1/" + std::to_wstring(m_nDstId) + L"/";
CHtmlFile oFile;
std::wstring sMetaInfo;
int nResult = oFile.ConvertEpub(sSrc, sMetaInfo, sDstFolder, sPath);
nResult;
m_pCounter->Decrement();
return 0;
}
};
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
...@@ -36,10 +107,29 @@ int main(int argc, char *argv[]) ...@@ -36,10 +107,29 @@ int main(int argc, char *argv[])
std::wstring sDstFolder = L"/home/oleg/activex/1/"; std::wstring sDstFolder = L"/home/oleg/activex/1/";
#endif #endif
#if 1
CHtmlFile oFile; CHtmlFile oFile;
std::wstring sMetaInfo; std::wstring sMetaInfo;
int nResult = oFile.ConvertEpub(sSrc, sMetaInfo, sDstFolder, sPath); int nResult = oFile.ConvertEpub(sSrc, sMetaInfo, sDstFolder, sPath);
nResult; nResult;
#else
int nCountTC = 1;
CCounter oCounter;
oCounter.Increment(nCountTC);
for (int i = 0; i < nCountTC; i++)
{
CThreadConverter* pThread = new CThreadConverter();
pThread->SetCounter(&oCounter);
pThread->m_nDstId = i;
pThread->Start(0);
}
while (0 != oCounter.GetCounter())
NSThreads::Sleep(100);
#endif
#endif #endif
......
...@@ -49,6 +49,7 @@ linux-g++:!contains(QMAKE_HOST.arch, x86_64):{ ...@@ -49,6 +49,7 @@ linux-g++:!contains(QMAKE_HOST.arch, x86_64):{
} }
LIBS += -L$$DESTINATION_SDK_PATH -lHtmlFile LIBS += -L$$DESTINATION_SDK_PATH -lHtmlFile
LIBS += -L$$DESTINATION_SDK_PATH -lgraphics
win32 { win32 {
LIBS += -ladvapi32 \ LIBS += -ladvapi32 \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment