From 23cbacc0c9cc4ff135ecaccae61b66653a818861 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Tue, 8 Jul 2014 17:26:23 +0200 Subject: [PATCH] SDL2: Compile fix --HG-- branch : sdl2 --- code/nel/include/nel/misc/thread.h | 2 +- .../samples/net/net_layer5/flood_service.cpp | 2 +- code/nel/samples/net/udp/bench_service.cpp | 28 ++-- .../nel/tools/nel_unit_test/ut_misc_co_task.h | 6 +- .../nel_launcher_windows/patch.cpp | 42 +++--- .../nel_launcher_windows_ext/patch.cpp | 122 ++++++++-------- .../nel_launcher_windows_ext2/patch.cpp | 132 +++++++++--------- .../patchman_service/stdin_monitor_thread.cpp | 4 +- .../client/client_data_check/data_scan.cpp | 36 ++--- .../client/client_data_check/data_scan.h | 20 +-- 10 files changed, 197 insertions(+), 197 deletions(-) diff --git a/code/nel/include/nel/misc/thread.h b/code/nel/include/nel/misc/thread.h index aa87565ed..1f8b61301 100644 --- a/code/nel/include/nel/misc/thread.h +++ b/code/nel/include/nel/misc/thread.h @@ -69,7 +69,7 @@ public: } }; -/// Thread priorities, numbering follows Win32 for now +/// Thread priorities enum TThreadPriority { ThreadPriorityLow, diff --git a/code/nel/samples/net/net_layer5/flood_service.cpp b/code/nel/samples/net/net_layer5/flood_service.cpp index 16eb858c6..b29be32e8 100644 --- a/code/nel/samples/net/net_layer5/flood_service.cpp +++ b/code/nel/samples/net/net_layer5/flood_service.cpp @@ -180,7 +180,7 @@ public: for (i=0; istart(); } } diff --git a/code/nel/samples/net/udp/bench_service.cpp b/code/nel/samples/net/udp/bench_service.cpp index 981a0dd0a..ccc95787f 100644 --- a/code/nel/samples/net/udp/bench_service.cpp +++ b/code/nel/samples/net/udp/bench_service.cpp @@ -140,7 +140,7 @@ CBufFIFO *CurrentReadQueue = NULL; TReceivedMessage *CurrentInMsg = NULL; -IThread *ReceiveThread = NULL; +CThread *ReceiveThread = NULL; CReceiveTask *ReceiveTask = NULL; list Clients; // contains all clients @@ -259,7 +259,7 @@ void CClient::updatePong (sint64 pingTime, sint64 pongTime, uint32 pongNumber, u // increase only for new pong NbPong++; MeanPongTime += (uint32)(pongTime-pingTime); - + FullNbPong++; FullMeanPongTime += (uint32)(pongTime-pingTime); @@ -276,7 +276,7 @@ void CClient::updatePong (sint64 pingTime, sint64 pongTime, uint32 pongNumber, u ha = Address.ipAddress(); } string fn = StatPathName + ConnectionName + "_" + ha + "_" + getDate() + ".pong"; - + FILE *fp = fopen (fn.c_str(), "rt"); if (fp == NULL) { @@ -318,7 +318,7 @@ void CClient::updateFullStat () for (uint i = 0; i < LastPongReceived; i++) { if (PongReceived[i].first == 0) NbLost++; - else + else { NbPong++; NbDup += PongReceived[i].first - 1; @@ -333,7 +333,7 @@ void CClient::updateFullStat () ha = Address.ipAddress(); } string fn = StatPathName + ConnectionName + "_" + ha + "_" + getDate() + ".stat"; - + string line = "Full Summary: "; line += "NbPing " + toString(LastPongReceived) + " "; line += "NbPong " + toString(NbPong) + " "; @@ -375,7 +375,7 @@ void CClient::updateFullStat () ha = Address.ipAddress(); } string fn = StatPathName + ConnectionName + "_" + ha + "_" + getDate() + ".ping"; - + FILE *fp = fopen (fn.c_str(), "rt"); if (fp == NULL) { @@ -432,7 +432,7 @@ void CClient::updateStat () ha = Address.ipAddress(); } string fn = StatPathName + ConnectionName + "_" + ha + "_" + getDate() + ".stat"; - + string line; line += "NbPing " + toString(NbPing) + " "; line += "NbPong " + toString(NbPong) + " "; @@ -455,7 +455,7 @@ void CClient::updateStat () fprintf (fp, "HostAddress: %s\n", Address.asString().c_str()); FirstWrite = false; } - + fprintf (fp, "%s\n", line.c_str()); fclose (fp); } @@ -535,7 +535,7 @@ void handleReceivedPong (CClient *client, sint64 pongTime) uint32 session = 0; msgin.serial (session); - // Find a new udp connection, find the linked + // Find a new udp connection, find the linked list::iterator it; for (it = Clients.begin(); it != Clients.end(); it++) { @@ -630,7 +630,7 @@ void sendPing () class CBenchService : public IService { public: - + void init() { nlassert( ReceiveTask==NULL && ReceiveThread==NULL ); @@ -649,7 +649,7 @@ public: CurrentReadQueue = &Queue2; ReceiveTask->setWriteQueue( &Queue1 ); nlassert( ReceiveTask != NULL ); - ReceiveThread = IThread::create( ReceiveTask ); + ReceiveThread = CThread::create( ReceiveTask ); nlassert( ReceiveThread != NULL ); ReceiveThread->start(); @@ -704,7 +704,7 @@ public: // Handle the UDP message - // Retrieve client info or add one + // Retrieve client info or add one TClientMap::iterator ihm = ClientMap.find( CurrentInMsg->AddrFrom ); if ( ihm == ClientMap.end() ) { @@ -757,7 +757,7 @@ public: delete ReceiveThread; ReceiveThread = NULL; } - + if (ReceiveTask != NULL) { delete ReceiveTask; @@ -779,5 +779,5 @@ public: } }; - + NLNET_SERVICE_MAIN (CBenchService, "BS", "bench_service", 45459, EmptyCallbackArray, UDP_DIR, "") diff --git a/code/nel/tools/nel_unit_test/ut_misc_co_task.h b/code/nel/tools/nel_unit_test/ut_misc_co_task.h index 34b94b61e..19c181085 100644 --- a/code/nel/tools/nel_unit_test/ut_misc_co_task.h +++ b/code/nel/tools/nel_unit_test/ut_misc_co_task.h @@ -151,7 +151,7 @@ public: void tasksAndThreads() { - // test running task in two separate thread (this stress the + // test running task in two separate thread (this stress the // multithreading support of task). CoTask API ;ake use of // thread local storage API to store by thread current task info. @@ -159,7 +159,7 @@ public: result2.clear(); CTaskThread tt; - NLMISC::IThread *th = NLMISC::IThread::create(&tt); + NLMISC::CThread *th = NLMISC::CThread::create(&tt); CTask2 t2; @@ -196,7 +196,7 @@ public: TEST_ASSERT(referenceResultThread2[i] == result[i]); } } - + void runTasks() { /// Run two main task and two working task at once and check that the result diff --git a/code/nelns/login_system/nel_launcher_windows/patch.cpp b/code/nelns/login_system/nel_launcher_windows/patch.cpp index c3be964a1..e131fcd2a 100644 --- a/code/nelns/login_system/nel_launcher_windows/patch.cpp +++ b/code/nelns/login_system/nel_launcher_windows/patch.cpp @@ -63,7 +63,7 @@ string deleteFile (const string &filename, bool throwException=true) void setVersion(const std::string &version) { string fn = "VERSION"; - + setRWAccess(fn); FILE *fp = fopen (fn.c_str(), "wb"); if (fp == NULL) @@ -105,16 +105,16 @@ string getVersion() class CPatchThread : public IRunnable { public: - + CPatchThread(const string &sp, const string &sv, const std::string &urlOk, const std::string &urlFailed, const std::string &logSeparator) : ServerPath (sp), ServerVersion(sv), UrlOk(urlOk), UrlFailed(urlFailed), Ended(false), StateChanged(true), LogSeparator(logSeparator) { } - + bool Ended; // true if the thread have ended the patch bool PatchOk; // true if the patch was good string Url; // url to display after the patch - + string State; string StateLog; bool StateChanged; @@ -136,7 +136,7 @@ private: string ClientPatchPath = "./patch/"; string ServerRootPath = CPath::standardizePath (ServerPath); string DisplayedServerRootPath; // contains the serverpath without login and password - + uint pos = ServerRootPath.find ("@"); if (pos != string::npos) { @@ -198,7 +198,7 @@ private: const char *gzerr = gzerror (gz, &gzerrno); throw Exception ("Can't read '%s' : code=%d %s", DirFilename.c_str(), gzerrno, gzerr); } - + string b = buffer; uint pos1 = b.find ("/"); uint pos2 = b.find ("/", pos1+1); @@ -238,9 +238,9 @@ private: string path = ClientPatchPath + needToGetFilesList[i].Filename; nlinfo ("Get the file from '%s' to '%s'", string(DisplayedServerRootPath+needToGetFilesList[i].Filename).c_str(), path.c_str()); - + // get the new file - + downloadFile (ServerRootPath+needToGetFilesList[i].Filename+".ngz", path+".ngz"); // decompress it decompressFile (path+".ngz", needToGetFilesList[i].Date); @@ -280,7 +280,7 @@ private: // special case for nel_launcher.exe if (needToGetFilesList[i].Filename == "nel_launcher.exe") continue; - + string path = ClientRootPath+needToGetFilesList[i].Filename; if (!NLMISC::CFile::fileExists (path)) { @@ -308,7 +308,7 @@ private: } // now, we have to delete files that are not in the server list - + setState(true, "Scanning patch directory"); vector res; CPath::getPathContent(ClientPatchPath, false, false, true, res); @@ -337,11 +337,11 @@ private: setState (true, "Deleting %s", DirFilename.c_str()); string err = deleteFile (DirFilename, false); if (!err.empty()) setState(true, err.c_str()); - + // now that all is ok, we set the new client version setState (true, "set client version to %s", ServerVersion.c_str ()); setVersion (ServerVersion); - + if (needToExecuteAPatch) { setState (true, "Launching patch_execute.bat"); @@ -358,7 +358,7 @@ private: nlinfo ("Patching completed"); setState (true, "Patching completed"); - + Url = UrlOk; PatchOk = true; Ended = true; @@ -401,12 +401,12 @@ private: if (fp == NULL) { string err = toString("Can't open file '%s' : code=%d %s", dest.c_str(), errno, strerror(errno)); - + gzclose(gz); deleteFile (filename); throw Exception (err); } - + uint8 buffer[10000]; while (!gzeof(gz)) { @@ -473,7 +473,7 @@ private: errorstr = (LPCTSTR)lpMsgBuf; } LocalFree(lpMsgBuf); - + throw Exception ("InternetOpen() failed: %s (ec %d)", errorstr.c_str(), errcode); } } @@ -523,7 +523,7 @@ private: errorstr = (LPCTSTR)lpMsgBuf; } LocalFree(lpMsgBuf); - + throw Exception ("InternetOpenUrl() failed on file '%s': %s (ec %d)", source.c_str (), errorstr.c_str(), errcode); } else @@ -543,7 +543,7 @@ private: deleteFile (dest); throw Exception (err); } - + CurrentBytesToGet += realSize; if (TotalBytesToGet == 0 && TotalFilesToGet == 0) @@ -568,7 +568,7 @@ private: errorstr = (LPCTSTR)lpMsgBuf; } LocalFree(lpMsgBuf); - + throw Exception ("InternetCloseHandle() failed on file '%s': %s (ec %d)", source.c_str (), errorstr.c_str(), errcode); } } @@ -611,11 +611,11 @@ void startPatchThread (const std::string &serverPath, const std::string &serverV nlwarning ("patch thread already running"); return; } - + PatchThread = new CPatchThread (serverPath, serverVersion, urlOk, urlFailed, logSeparator); nlassert (PatchThread != NULL); - IThread *thread = IThread::create (PatchThread); + CThread *thread = CThread::create (PatchThread); nlassert (thread != NULL); thread->start (); } diff --git a/code/nelns/login_system/nel_launcher_windows_ext/patch.cpp b/code/nelns/login_system/nel_launcher_windows_ext/patch.cpp index 81253989f..00be26d71 100644 --- a/code/nelns/login_system/nel_launcher_windows_ext/patch.cpp +++ b/code/nelns/login_system/nel_launcher_windows_ext/patch.cpp @@ -96,7 +96,7 @@ string deleteFile (const string &filename, bool throwException=true) void setVersion(const std::string &version) { string fn = "VERSION"; - + setRWAccess(fn); FILE *fp = fopen (fn.c_str(), "wb"); if (fp == NULL) @@ -138,16 +138,16 @@ string getVersion() class CPatchThread : public IRunnable { public: - + CPatchThread(const string &sp, const string &sv, const std::string &urlOk, const std::string &urlFailed, const std::string &logSeparator) : ServerPath (sp), ServerVersion(sv), UrlOk(urlOk), UrlFailed(urlFailed), Ended(false), StateChanged(true), LogSeparator(logSeparator) { } - + bool Ended; // true if the thread have ended the patch bool PatchOk; // true if the patch was good string Url; // url to display after the patch - + string State; string StateLog; bool StateChanged; @@ -158,7 +158,7 @@ private: string ClientPatchPath; // the patch path (c:\ryzom\patch) string ServerRootPath; // the root server path (http://www.toto.com) string DisplayedServerRootPath; // contains the serverpath without login and password - + // get a file and decompress it in the patch directory void getFile (const CEntry &e) { @@ -186,7 +186,7 @@ private: ClientPatchPath = "./patch/"; ServerRootPath = CPath::standardizePath (ServerPath); DisplayedServerRootPath; // contains the serverpath without login and password - + uint pos = ServerRootPath.find ("@"); if (pos != string::npos) { @@ -248,7 +248,7 @@ private: const char *gzerr = gzerror (gz, &gzerrno); throw Exception ("Can't read '%s' : code=%d %s", DirFilename.c_str(), gzerrno, gzerr); } - + string b = buffer; uint pos1 = b.find ("/"); uint pos2 = b.find ("/", pos1+1); @@ -280,7 +280,7 @@ private: // nel_launcher.exe and relaunch it now bool patchExe = false, patchCfg = false, patchBat = false; - + uint i; for (i = 0; i < needToGetFilesList.size(); i++) @@ -307,42 +307,42 @@ private: if (patchBat) { setState (true, true, "Launching %s", RelaunchNelLauncherBatchFilename.c_str()); - + //if (_execlp ("update_nel_launcher.bat", "update_nel_launcher.bat", NULL) == -1) STARTUPINFO si; PROCESS_INFORMATION pi; - + ZeroMemory( &si, sizeof(si) ); // Flag permettant de prendre en compte wShowWindow si.dwFlags = STARTF_USESHOWWINDOW; si.wShowWindow = SW_HIDE; - + si.cb = sizeof(si); - + ZeroMemory( &pi, sizeof(pi) ); - - // Start the child process. - if( !CreateProcess( NULL, // No module name (use command line). - (char*)RelaunchNelLauncherBatchFilename.c_str(), // Command line. - NULL, // Process handle not inheritable. - NULL, // Thread handle not inheritable. - FALSE, // Set handle inheritance to FALSE. - 0, // No creation flags. - NULL, // Use parent's environment block. - NULL, // Use parent's starting directory. + + // Start the child process. + if( !CreateProcess( NULL, // No module name (use command line). + (char*)RelaunchNelLauncherBatchFilename.c_str(), // Command line. + NULL, // Process handle not inheritable. + NULL, // Thread handle not inheritable. + FALSE, // Set handle inheritance to FALSE. + 0, // No creation flags. + NULL, // Use parent's environment block. + NULL, // Use parent's starting directory. &si, // Pointer to STARTUPINFO structure. &pi ) // Pointer to PROCESS_INFORMATION structure. - ) + ) { // error occurs during the launch string str = toString("Can't execute '%s': code=%d %s", RelaunchNelLauncherBatchFilename.c_str(), errno, strerror(errno)); throw Exception (str); } - - // Close process and thread handles. + + // Close process and thread handles. CloseHandle( pi.hProcess ); CloseHandle( pi.hThread ); - + exit(0); } else if (patchExe || patchCfg) @@ -355,7 +355,7 @@ private: } fprintf(fp, "@echo off\n"); - + if (patchExe) { nlinfo ("Need to special patch '%s'",NelLauncherFilename.c_str()); @@ -379,52 +379,52 @@ private: } fprintf(fp, "start %s\n", NelLauncherFilename.c_str()); - + fclose (fp); // remove the files list file setState (true, true, "Deleting %s", DirFilename.c_str()); string err = deleteFile (DirFilename, false); if (!err.empty()) setState(true, true, err.c_str()); - + // launching the .bat setState (true, true, "Launching %s", UpdateNelLauncherBatchFilename.c_str()); - + //if (_execlp ("update_nel_launcher.bat", "update_nel_launcher.bat", NULL) == -1) STARTUPINFO si; PROCESS_INFORMATION pi; - + ZeroMemory( &si, sizeof(si) ); // Flag permettant de prendre en compte wShowWindow si.dwFlags = STARTF_USESHOWWINDOW; si.wShowWindow = SW_HIDE; - + si.cb = sizeof(si); - + ZeroMemory( &pi, sizeof(pi) ); - - // Start the child process. - if( !CreateProcess( NULL, // No module name (use command line). - (char*)UpdateNelLauncherBatchFilename.c_str(), // Command line. - NULL, // Process handle not inheritable. - NULL, // Thread handle not inheritable. - FALSE, // Set handle inheritance to FALSE. - 0, // No creation flags. - NULL, // Use parent's environment block. - NULL, // Use parent's starting directory. + + // Start the child process. + if( !CreateProcess( NULL, // No module name (use command line). + (char*)UpdateNelLauncherBatchFilename.c_str(), // Command line. + NULL, // Process handle not inheritable. + NULL, // Thread handle not inheritable. + FALSE, // Set handle inheritance to FALSE. + 0, // No creation flags. + NULL, // Use parent's environment block. + NULL, // Use parent's starting directory. &si, // Pointer to STARTUPINFO structure. &pi ) // Pointer to PROCESS_INFORMATION structure. - ) + ) { // error occurs during the launch string str = toString("Can't execute '%s': code=%d %s", UpdateNelLauncherBatchFilename.c_str(), errno, strerror(errno)); throw Exception (str); } - - // Close process and thread handles. + + // Close process and thread handles. CloseHandle( pi.hProcess ); CloseHandle( pi.hThread ); - + exit(0); } @@ -442,12 +442,12 @@ private: { executeFinalizeBat = true; } - + // put the file in the ryzom patch directory string path = ClientPatchPath + needToGetFilesList[i].Filename; //nldebug ("path '%s' -> %d %s", path.c_str(), NLMISC::CFile::fileExists (ClientRootPath + needToGetFilesList[i].Filename), strlwr(NLMISC::CFile::getExtension(needToGetFilesList[i].Filename)).c_str()); - + // move dll exe and already existing file in the root directory if (NLMISC::CFile::fileExists (ClientRootPath + needToGetFilesList[i].Filename) || strlwr(NLMISC::CFile::getExtension(needToGetFilesList[i].Filename)) == "dll" || @@ -471,7 +471,7 @@ private: } // now, we have to delete files that are not in the server list - + setState(true, true, "Scanning patch directory"); vector res; CPath::getPathContent(ClientPatchPath, false, false, true, res); @@ -512,10 +512,10 @@ private: setState (true, true, "Launching %s", fn.c_str()); system(fn.c_str()); } - + // it s the end of the patch process setState (true, true, "Patching completed"); - + Url = UrlOk; PatchOk = true; Ended = true; @@ -558,12 +558,12 @@ private: if (fp == NULL) { string err = toString("Can't open file '%s' : code=%d %s", dest.c_str(), errno, strerror(errno)); - + gzclose(gz); deleteFile (filename); throw Exception (err); } - + uint32 currentSize = 0; uint8 buffer[10000]; while (!gzeof(gz)) @@ -633,7 +633,7 @@ private: errorstr = (LPCTSTR)lpMsgBuf; } LocalFree(lpMsgBuf); - + throw Exception ("InternetOpen() failed: %s (ec %d)", errorstr.c_str(), errcode); } } @@ -683,7 +683,7 @@ private: errorstr = (LPCTSTR)lpMsgBuf; } LocalFree(lpMsgBuf); - + throw Exception ("InternetOpenUrl() failed on file '%s': %s (ec %d)", source.c_str (), errorstr.c_str(), errcode); } else @@ -703,7 +703,7 @@ private: deleteFile (dest); throw Exception (err); } - + CurrentBytesToGet += realSize; if (TotalBytesToGet == 0 && TotalFilesToGet == 0) @@ -728,7 +728,7 @@ private: errorstr = (LPCTSTR)lpMsgBuf; } LocalFree(lpMsgBuf); - + throw Exception ("InternetCloseHandle() failed on file '%s': %s (ec %d)", source.c_str (), errorstr.c_str(), errcode); } } @@ -742,7 +742,7 @@ private: nlinfo (str); State = str; if(log) - { + { StateLog += str; StateLog += LogSeparator; } @@ -773,11 +773,11 @@ void startPatchThread (const std::string &serverPath, const std::string &serverV nlwarning ("patch thread already running"); return; } - + PatchThread = new CPatchThread (serverPath, serverVersion, urlOk, urlFailed, logSeparator); nlassert (PatchThread != NULL); - IThread *thread = IThread::create (PatchThread); + CThread *thread = CThread::create (PatchThread); nlassert (thread != NULL); thread->start (); } diff --git a/code/nelns/login_system/nel_launcher_windows_ext2/patch.cpp b/code/nelns/login_system/nel_launcher_windows_ext2/patch.cpp index a60f129fa..697eb913f 100644 --- a/code/nelns/login_system/nel_launcher_windows_ext2/patch.cpp +++ b/code/nelns/login_system/nel_launcher_windows_ext2/patch.cpp @@ -110,7 +110,7 @@ void setVersion(const std::string &version) if(VerboseLog) nlinfo("setVersion to '%s'", version.c_str()); string fn = "VERSION"; - + setRWAccess(fn); FILE *fp = fopen (fn.c_str(), "wb"); if (fp == NULL) @@ -157,16 +157,16 @@ int myProgressFunc(void *foo, double t, double d, double ultotal, double ulnow); class CPatchThread : public IRunnable { public: - + CPatchThread(const string &sp, const string &sv, const std::string &urlOk, const std::string &urlFailed, const std::string &logSeparator) : ServerPath (sp), ServerVersion(sv), UrlOk(urlOk), UrlFailed(urlFailed), Ended(false), StateChanged(true), LogSeparator(logSeparator) { } - + bool Ended; // true if the thread have ended the patch bool PatchOk; // true if the patch was good string Url; // url to display after the patch - + string State; string StateLog; bool StateChanged; @@ -177,7 +177,7 @@ private: string ClientPatchPath; // the patch path (c:\ryzom\patch) string ServerRootPath; // the root server path (http://www.toto.com) string DisplayedServerRootPath; // contains the serverpath without login and password - + // get a file and decompress it in the patch directory void getFile (const CEntry &e) { @@ -207,7 +207,7 @@ private: ClientPatchPath = "./patch/"; ServerRootPath = CPath::standardizePath (ServerPath)+ServerVersion+"/"; DisplayedServerRootPath; // contains the serverpath without login and password - + uint pos = ServerRootPath.find ("@"); if (pos != string::npos) { @@ -269,7 +269,7 @@ private: const char *gzerr = gzerror (gz, &gzerrno); throw Exception ("Can't read '%s' : code=%d %s (error code 27)", DirFilename.c_str(), gzerrno, gzerr); } - + string b = buffer; uint pos1 = b.find ("/"); uint pos2 = b.find ("/", pos1+1); @@ -309,7 +309,7 @@ private: // nel_launcher.exe and relaunch it now bool patchExe = false, patchCfg = false, patchBat = false; - + uint i; for (i = 0; i < needToGetFilesList.size(); i++) @@ -336,42 +336,42 @@ private: if (patchBat) { setState (true, true, "Launching %s", RelaunchNelLauncherBatchFilename.c_str()); - + //if (_execlp ("update_nel_launcher.bat", "update_nel_launcher.bat", NULL) == -1) STARTUPINFO si; PROCESS_INFORMATION pi; - + ZeroMemory( &si, sizeof(si) ); // Flag permettant de prendre en compte wShowWindow si.dwFlags = STARTF_USESHOWWINDOW; si.wShowWindow = SW_HIDE; - + si.cb = sizeof(si); - + ZeroMemory( &pi, sizeof(pi) ); - - // Start the child process. - if( !CreateProcess( NULL, // No module name (use command line). - (char*)RelaunchNelLauncherBatchFilename.c_str(), // Command line. - NULL, // Process handle not inheritable. - NULL, // Thread handle not inheritable. - FALSE, // Set handle inheritance to FALSE. - 0, // No creation flags. - NULL, // Use parent's environment block. - NULL, // Use parent's starting directory. + + // Start the child process. + if( !CreateProcess( NULL, // No module name (use command line). + (char*)RelaunchNelLauncherBatchFilename.c_str(), // Command line. + NULL, // Process handle not inheritable. + NULL, // Thread handle not inheritable. + FALSE, // Set handle inheritance to FALSE. + 0, // No creation flags. + NULL, // Use parent's environment block. + NULL, // Use parent's starting directory. &si, // Pointer to STARTUPINFO structure. &pi ) // Pointer to PROCESS_INFORMATION structure. - ) + ) { // error occurs during the launch string str = toString("Can't execute '%s': code=%d %s (error code 28)", RelaunchNelLauncherBatchFilename.c_str(), errno, strerror(errno)); throw Exception (str); } - - // Close process and thread handles. + + // Close process and thread handles. CloseHandle( pi.hProcess ); CloseHandle( pi.hThread ); - + exit(0); } else if (patchExe || patchCfg) @@ -384,7 +384,7 @@ private: } fprintf(fp, "@echo off\n"); - + if (patchExe) { nlinfo ("Need to special patch '%s'",NelLauncherFilename.c_str()); @@ -408,52 +408,52 @@ private: } fprintf(fp, "start %s\n", NelLauncherFilename.c_str()); - + fclose (fp); // remove the files list file setState (true, true, "Deleting %s", DirFilename.c_str()); string err = deleteFile (DirFilename, false); if (!err.empty()) setState(true, true, err.c_str()); - + // launching the .bat setState (true, true, "Launching %s", UpdateNelLauncherBatchFilename.c_str()); - + //if (_execlp ("update_nel_launcher.bat", "update_nel_launcher.bat", NULL) == -1) STARTUPINFO si; PROCESS_INFORMATION pi; - + ZeroMemory( &si, sizeof(si) ); // Flag permettant de prendre en compte wShowWindow si.dwFlags = STARTF_USESHOWWINDOW; si.wShowWindow = SW_HIDE; - + si.cb = sizeof(si); - + ZeroMemory( &pi, sizeof(pi) ); - - // Start the child process. - if( !CreateProcess( NULL, // No module name (use command line). - (char*)UpdateNelLauncherBatchFilename.c_str(), // Command line. - NULL, // Process handle not inheritable. - NULL, // Thread handle not inheritable. - FALSE, // Set handle inheritance to FALSE. - 0, // No creation flags. - NULL, // Use parent's environment block. - NULL, // Use parent's starting directory. + + // Start the child process. + if( !CreateProcess( NULL, // No module name (use command line). + (char*)UpdateNelLauncherBatchFilename.c_str(), // Command line. + NULL, // Process handle not inheritable. + NULL, // Thread handle not inheritable. + FALSE, // Set handle inheritance to FALSE. + 0, // No creation flags. + NULL, // Use parent's environment block. + NULL, // Use parent's starting directory. &si, // Pointer to STARTUPINFO structure. &pi ) // Pointer to PROCESS_INFORMATION structure. - ) + ) { // error occurs during the launch string str = toString("Can't execute '%s': code=%d %s (error code 30)", UpdateNelLauncherBatchFilename.c_str(), errno, strerror(errno)); throw Exception (str); } - - // Close process and thread handles. + + // Close process and thread handles. CloseHandle( pi.hProcess ); CloseHandle( pi.hThread ); - + quit(); } @@ -471,12 +471,12 @@ private: { executeFinalizeBat = true; } - + // put the file in the ryzom patch directory string path = ClientPatchPath + needToGetFilesList[i].Filename; //nldebug ("path '%s' -> %d %s", path.c_str(), NLMISC::CFile::fileExists (ClientRootPath + needToGetFilesList[i].Filename), strlwr(NLMISC::CFile::getExtension(needToGetFilesList[i].Filename)).c_str()); - + // move dll exe and already existing file in the root directory if (NLMISC::CFile::fileExists (ClientRootPath + needToGetFilesList[i].Filename) || strlwr(NLMISC::CFile::getExtension(needToGetFilesList[i].Filename)) == "dll" || @@ -500,7 +500,7 @@ private: } // now, we have to delete files that are not in the server list - + setState(true, true, "Scanning patch directory"); vector res; CPath::getPathContent(ClientPatchPath, false, false, true, res); @@ -541,10 +541,10 @@ private: setState (true, true, "Launching %s", fn.c_str()); system(fn.c_str()); } - + // it s the end of the patch process setState (true, true, "Patching completed"); - + Url = UrlOk; PatchOk = true; Ended = true; @@ -590,12 +590,12 @@ private: if (fp == NULL) { string err = toString("Can't open file '%s' : code=%d %s, (error code 32)", dest.c_str(), errno, strerror(errno)); - + gzclose(gz); deleteFile (filename); throw Exception (err); } - + if(VerboseLog) nlinfo("Entering the while loop decompression"); uint32 currentSize = 0; @@ -656,7 +656,7 @@ private: } if(VerboseLog) nlinfo("Exiting the decompressing file"); } - + void downloadFileWithCurl (const string &source, const string &dest) { #ifdef USE_CURL @@ -723,7 +723,7 @@ private: // file not found, delete it NLMISC::CFile::deleteFile(dest.c_str()); throw Exception ("curl download failed: (ec %d %d)", res, r); - } + } #else throw Exception("USE_CURL is not defined, no curl method"); #endif @@ -747,7 +747,7 @@ private: uint8 buffer[bufferSize]; if(VerboseLog) nlinfo("downloadFile '%s'", dest.c_str()); - + if (RootInternet == NULL) { RootInternet = InternetOpen("nel_launcher", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); @@ -768,7 +768,7 @@ private: { errorstr = "FormatMessage can't get the message"; } - + throw Exception ("InternetOpen() failed: %s (ec %d) (error code 35)", errorstr.c_str(), errcode); } } @@ -826,7 +826,7 @@ private: { errorstr = "FormatMessage can't get the message"; } - + fclose(fp); deleteFile (dest); @@ -849,7 +849,7 @@ private: deleteFile (dest); throw Exception (err); } - + CurrentBytesToGet += realSize; if (TotalBytesToGet == 0 && TotalFilesToGet == 0) @@ -878,7 +878,7 @@ private: { errorstr = "FormatMessage can't get the message"; } - + throw Exception ("InternetCloseHandle() failed on file '%s': %s (ec %d) (error code 40)", source.c_str (), errorstr.c_str(), errcode); } } @@ -892,7 +892,7 @@ private: nlinfo (str); State = str; if(log) - { + { StateLog += str; StateLog += LogSeparator; } @@ -907,7 +907,7 @@ private: string UrlOk; string UrlFailed; - friend int myProgressFunc(void *foo, double t, double d, double ultotal, double ulnow); + friend int myProgressFunc(void *foo, double t, double d, double ultotal, double ulnow); public: uint TotalFilesToGet; @@ -917,7 +917,7 @@ public: }; CPatchThread *PatchThread = NULL; -IThread *thread = NULL; +CThread *thread = NULL; int myProgressFunc(void *foo, double t, double d, double ultotal, double ulnow) { @@ -936,11 +936,11 @@ void startPatchThread (const std::string &serverPath, const std::string &serverV nlwarning ("patch thread already running"); return; } - + PatchThread = new CPatchThread (serverPath, serverVersion, urlOk, urlFailed, logSeparator); nlassert (PatchThread != NULL); - thread = IThread::create (PatchThread); + thread = CThread::create (PatchThread); nlassert (thread != NULL); thread->start (); } diff --git a/code/ryzom/server/src/patchman_service/stdin_monitor_thread.cpp b/code/ryzom/server/src/patchman_service/stdin_monitor_thread.cpp index b9345e09d..171e3cd69 100644 --- a/code/ryzom/server/src/patchman_service/stdin_monitor_thread.cpp +++ b/code/ryzom/server/src/patchman_service/stdin_monitor_thread.cpp @@ -144,7 +144,7 @@ private: private: // data for the singleton instance CStdinMonitorThread* _StdinMonitorThreadInstance; - NLMISC::IThread* _StdinMonitorThreadHandle; + NLMISC::CThread* _StdinMonitorThreadHandle; }; CStdinMonitorSingleton StdinMonitorSingleton; @@ -165,7 +165,7 @@ static CStdinMonitorSingleton& getInstance() void CStdinMonitorSingleton::init() { _StdinMonitorThreadInstance= new CStdinMonitorThread; - _StdinMonitorThreadHandle = NLMISC::IThread::create (_StdinMonitorThreadInstance); + _StdinMonitorThreadHandle = NLMISC::CThread::create (_StdinMonitorThreadInstance); _StdinMonitorThreadHandle->start(); } diff --git a/code/ryzom/tools/client/client_data_check/data_scan.cpp b/code/ryzom/tools/client/client_data_check/data_scan.cpp index 7031aaa92..9ca168c67 100644 --- a/code/ryzom/tools/client/client_data_check/data_scan.cpp +++ b/code/ryzom/tools/client/client_data_check/data_scan.cpp @@ -159,7 +159,7 @@ int CPatchManager::getTotalFilesToGet() { if (ScanDataThread != NULL) return ScanDataThread->TotalFileToScan; - + return 1; } @@ -168,7 +168,7 @@ int CPatchManager::getCurrentFilesToGet() { if (ScanDataThread != NULL) return ScanDataThread->CurrentFileScanned; - + return 1; } @@ -226,7 +226,7 @@ void CPatchManager::getPatchFromDesc(SFileToPatch &ftpOut, const CBNPFile &fIn, ftpOut.FileName = rFilename; ftpOut.LocalFileToDelete = false; ftpOut.LocalFileExists = false; - // It happens some time (maybe a bug) that the versionCount is 0... => + // It happens some time (maybe a bug) that the versionCount is 0... => // it happens if the BNP file is empty (8 bytes) ftpOut.FinalFileSize = EmptyBnpFileSize; // BNP does not exists : get all the patches version @@ -261,7 +261,7 @@ void CPatchManager::getPatchFromDesc(SFileToPatch &ftpOut, const CBNPFile &fIn, } } } - + // If the version cannot be found with size and time try with sha1 if (nVersionFound == 0xFFFFFFFF) { @@ -280,7 +280,7 @@ void CPatchManager::getPatchFromDesc(SFileToPatch &ftpOut, const CBNPFile &fIn, } } } - + // No version available found if (nVersionFound == 0xFFFFFFFF) { @@ -290,7 +290,7 @@ void CPatchManager::getPatchFromDesc(SFileToPatch &ftpOut, const CBNPFile &fIn, ftpOut.FileName = rFilename; ftpOut.LocalFileToDelete = true; ftpOut.LocalFileExists = true; - // It happens some time (maybe a bug) that the versionCount is 0... => + // It happens some time (maybe a bug) that the versionCount is 0... => // it happens if the BNP file is empty (8 bytes) ftpOut.FinalFileSize = EmptyBnpFileSize; // Get all the patches version @@ -314,7 +314,7 @@ void CPatchManager::getPatchFromDesc(SFileToPatch &ftpOut, const CBNPFile &fIn, for (j = 0; j < rFile.versionCount(); ++j) if (rFile.getVersion(j).getVersionNumber() == nVersionFound) break; - + nlassert(j != rFile.versionCount()); // Not normal if we cant find the version we found previously // Point on the next version @@ -335,7 +335,7 @@ void CPatchManager::getPatchFromDesc(SFileToPatch &ftpOut, const CBNPFile &fIn, // For info, get its final file size ftpOut.FinalFileSize= rFile.getVersion(rFile.versionCount()-1).getFileSize(); } - } // end of else local BNP file exists + } // end of else local BNP file exists } @@ -352,7 +352,7 @@ void CPatchManager::startScanDataThread() nlwarning ("a thread is already running"); return; } - + // Reset result clearDataScanLog(); @@ -362,8 +362,8 @@ void CPatchManager::startScanDataThread() // start thread ScanDataThread = new CScanDataThread(); nlassert (ScanDataThread != NULL); - - thread = IThread::create (ScanDataThread); + + thread = CThread::create (ScanDataThread); nlassert (thread != NULL); thread->start (); } @@ -376,14 +376,14 @@ bool CPatchManager::isScanDataThreadEnded(bool &ok) ok = false; return true; } - + bool end = ScanDataThread->Ended; if (end) { ok = ScanDataThread->CheckOk; stopScanDataThread(); } - + return end; } @@ -430,7 +430,7 @@ bool CPatchManager::getDataScanLog(ucstring &text) } // then reset val.Changed= false; - } + } return changed; } @@ -443,7 +443,7 @@ void CPatchManager::addDataScanLogCorruptedFile(const SFileToPatch &ftp) CDataScanState &val= ac.value(); val.FilesWithScanDataError.push_back(ftp); val.Changed= true; - } + } } // *************************************************************************** @@ -454,7 +454,7 @@ void CPatchManager::clearDataScanLog() CDataScanState &val= ac.value(); val.FilesWithScanDataError.clear(); val.Changed= true; - } + } } // *************************************************************************** @@ -494,8 +494,8 @@ void CScanDataThread::run () string sClientVersion = pPM->getClientVersion(); ucstring sTranslate = dummyI18N("Client Version") + " (" + sClientVersion + ") "; pPM->setState(true, sTranslate); - - // For all bnp in the description file get all patches to apply + + // For all bnp in the description file get all patches to apply // depending on the version of the client bnp files const CBNPFileSet &rDescFiles = pPM->DescFile.getFiles(); TotalFileToScan = rDescFiles.fileCount(); diff --git a/code/ryzom/tools/client/client_data_check/data_scan.h b/code/ryzom/tools/client/client_data_check/data_scan.h index be1c5ee59..dd7cd94ba 100644 --- a/code/ryzom/tools/client/client_data_check/data_scan.h +++ b/code/ryzom/tools/client/client_data_check/data_scan.h @@ -61,7 +61,7 @@ public: _Instance = new CPatchManager(); return _Instance; } - + // init void init(); @@ -69,31 +69,31 @@ public: std::string getClientVersion (); bool isVerboseLog() { return VerboseLog; } - + void setVerboseLog(bool b) { VerboseLog = b; } - // Get the string information about what the threads are doing + // Get the string information about what the threads are doing // Return true if the state has changed bool getThreadState (ucstring &state, std::vector &stateLog); // TODO : Revoir ca pour la seconde partie ... // On a peut etre pas les informations de taille des patches ... voir avec daniel // pour l'instant c'est un fake qui retourne 1 ! - + int getTotalFilesToGet(); int getCurrentFilesToGet(); // ---------------------------------------------- // ScanData Part : optional task wich verify all data // ---------------------------------------------- - + // start the full check of BNP void startScanDataThread(); // if the scan data thread has ended bool isScanDataThreadEnded(bool &ok); - // ask to stop the Scan Data thread. NB: for security, the thread will continue to the current scanned file, + // ask to stop the Scan Data thread. NB: for security, the thread will continue to the current scanned file, // then stop. Hence, you must still wait isScanDataThreadEnded() return true void askForStopScanDataThread(); @@ -109,7 +109,7 @@ private: // Set the thread state (called by threads to let us know what they are doing) void setState (bool bOutputToLog, const ucstring &ucsState); - + /// Read the description file (throw exception if it doesn't exists) void readDescFile(sint32 nVersion); @@ -126,7 +126,7 @@ private: void addDataScanLogCorruptedFile(const SFileToPatch &ftp); void clearDataScanLog(); static void getCorruptedFileInfo(const SFileToPatch &ftp, ucstring &sTranslate); - + private: /// Constructor @@ -143,7 +143,7 @@ private: // Threads CScanDataThread *ScanDataThread; - NLMISC::IThread *thread; + NLMISC::CThread *thread; // State struct CState @@ -197,7 +197,7 @@ public: public: // Written by MainThread, read by thread - bool AskForCancel; // true if the main thread ask to cancel the task + bool AskForCancel; // true if the main thread ask to cancel the task // Written by thread, read by Main Thread bool Ended; // true if the thread have ended