| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 1 #include <AdblockPlus.h> | 1 #include <AdblockPlus.h> |
| 2 #include <vector> | 2 #include <vector> |
| 3 #include <Windows.h> | 3 #include <Windows.h> |
| 4 | 4 |
| 5 #include "../shared/AutoHandle.h" | 5 #include "../shared/AutoHandle.h" |
| 6 #include "../shared/Communication.h" | 6 #include "../shared/Communication.h" |
| 7 #include "../shared/Utils.h" | 7 #include "../shared/Utils.h" |
| 8 #include "../shared/Version.h" | 8 #include "../shared/Version.h" |
| 9 #include "Debug.h" | 9 #include "Debug.h" |
| 10 | 10 |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 180 | 180 |
| 181 AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::New(appInfo); | 181 AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::New(appInfo); |
| 182 std::string dataPath = ToUtf8String(GetAppDataPath()); | 182 std::string dataPath = ToUtf8String(GetAppDataPath()); |
| 183 dynamic_cast<AdblockPlus::DefaultFileSystem*>(jsEngine->GetFileSystem().get()) ->SetBasePath(dataPath); | 183 dynamic_cast<AdblockPlus::DefaultFileSystem*>(jsEngine->GetFileSystem().get()) ->SetBasePath(dataPath); |
| 184 std::auto_ptr<AdblockPlus::FilterEngine> filterEngine(new AdblockPlus::FilterE ngine(jsEngine)); | 184 std::auto_ptr<AdblockPlus::FilterEngine> filterEngine(new AdblockPlus::FilterE ngine(jsEngine)); |
| 185 return filterEngine; | 185 return filterEngine; |
| 186 } | 186 } |
| 187 | 187 |
| 188 int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) | 188 int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) |
| 189 { | 189 { |
| 190 // TODO: Attempt to create the pipe first, and exit immediately if this | 190 if (Communication::PipeExists(Communication::pipeName)) |
| 191 // fails. Since multiple instances of the engine could be running, | 191 { |
| 192 // this may need named mutices to avoid race conditions. | 192 DebugLastError("Named pipe exists, another engine instance appears to be run ning"); |
| 193 // Note that as soon as the pipe is created first, we can reduce the | 193 return 1; |
| 194 // client timeout after CreateProcess(), but should increase the one | 194 } |
|
Wladimir Palant
2013/06/07 06:16:08
That's causing a race condition. It can take sever
Felix Dahlke
2013/06/07 06:37:22
Hm, you're right, this actually shouldn't work. Ma
| |
| 195 // in WaitNamedPipe(). | |
| 196 | 195 |
| 197 int argc; | 196 int argc; |
| 198 LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc); | 197 LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc); |
| 199 std::wstring locale(argc >= 1 ? argv[0] : L""); | 198 std::wstring locale(argc >= 1 ? argv[0] : L""); |
| 200 LocalFree(argv); | 199 LocalFree(argv); |
| 201 | 200 |
| 202 filterEngine = CreateFilterEngine(locale); | 201 filterEngine = CreateFilterEngine(locale); |
| 203 | 202 |
| 204 for (;;) | 203 for (;;) |
| 205 { | 204 { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 219 } | 218 } |
| 220 catch (std::runtime_error e) | 219 catch (std::runtime_error e) |
| 221 { | 220 { |
| 222 DebugException(e); | 221 DebugException(e); |
| 223 return 1; | 222 return 1; |
| 224 } | 223 } |
| 225 } | 224 } |
| 226 | 225 |
| 227 return 0; | 226 return 0; |
| 228 } | 227 } |
| OLD | NEW |