OLD | NEW |
1 #include <AdblockPlus.h> | 1 #include <AdblockPlus.h> |
2 #include <functional> | 2 #include <functional> |
3 #include <vector> | 3 #include <vector> |
4 #include <Windows.h> | 4 #include <Windows.h> |
5 | 5 |
6 #include "../shared/AutoHandle.h" | 6 #include "../shared/AutoHandle.h" |
7 #include "../shared/Communication.h" | 7 #include "../shared/Communication.h" |
8 #include "../shared/Dictionary.h" | 8 #include "../shared/Dictionary.h" |
9 #include "../shared/Utils.h" | 9 #include "../shared/Utils.h" |
10 #include "../shared/Version.h" | 10 #include "../shared/Version.h" |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 DebugLastError("CreateMutex failed"); | 200 DebugLastError("CreateMutex failed"); |
201 return 1; | 201 return 1; |
202 } | 202 } |
203 | 203 |
204 if (GetLastError() == ERROR_ALREADY_EXISTS) | 204 if (GetLastError() == ERROR_ALREADY_EXISTS) |
205 { | 205 { |
206 DebugLastError("Named pipe exists, another engine instance appears to be run
ning"); | 206 DebugLastError("Named pipe exists, another engine instance appears to be run
ning"); |
207 return 1; | 207 return 1; |
208 } | 208 } |
209 | 209 |
210 int argc; | |
211 LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc); | |
212 std::wstring locale(argc >= 2 ? argv[1] : L""); | |
213 LocalFree(argv); | |
214 | |
215 Dictionary::Create(locale); | |
216 filterEngine = CreateFilterEngine(locale); | |
217 | |
218 for (;;) | 210 for (;;) |
219 { | 211 { |
220 try | 212 try |
221 { | 213 { |
222 Communication::Pipe* pipe = new Communication::Pipe(Communication::pipeNam
e, | 214 Communication::Pipe* pipe = new Communication::Pipe(Communication::pipeNam
e, |
223 Communication::Pipe::MODE_CREATE); | 215 Communication::Pipe::MODE_CREATE); |
224 | 216 |
| 217 if (!filterEngine.get()) |
| 218 { |
| 219 int argc; |
| 220 LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc); |
| 221 std::wstring locale(argc >= 2 ? argv[1] : L""); |
| 222 LocalFree(argv); |
| 223 Dictionary::Create(locale); |
| 224 filterEngine = CreateFilterEngine(locale); |
| 225 } |
| 226 |
225 // TODO: Count established connections, kill the engine when none are left | 227 // TODO: Count established connections, kill the engine when none are left |
226 AutoHandle thread(CreateThread(0, 0, ClientThread, static_cast<LPVOID>(pip
e), 0, 0)); | 228 AutoHandle thread(CreateThread(0, 0, ClientThread, static_cast<LPVOID>(pip
e), 0, 0)); |
227 if (!thread) | 229 if (!thread) |
228 { | 230 { |
229 delete pipe; | 231 delete pipe; |
230 DebugLastError("CreateThread failed"); | 232 DebugLastError("CreateThread failed"); |
231 return 1; | 233 return 1; |
232 } | 234 } |
233 } | 235 } |
234 catch (std::runtime_error e) | 236 catch (std::runtime_error e) |
235 { | 237 { |
236 DebugException(e); | 238 DebugException(e); |
237 return 1; | 239 return 1; |
238 } | 240 } |
239 } | 241 } |
240 | 242 |
241 return 0; | 243 return 0; |
242 } | 244 } |
OLD | NEW |