OLD | NEW |
1 #include "PluginStdAfx.h" | 1 #include "PluginStdAfx.h" |
2 | 2 |
3 #include "PluginSettings.h" | 3 #include "PluginSettings.h" |
4 #include "PluginSystem.h" | 4 #include "PluginSystem.h" |
5 #include "PluginFilter.h" | 5 #include "PluginFilter.h" |
6 #include "PluginClientFactory.h" | 6 #include "PluginClientFactory.h" |
7 #include "PluginDictionary.h" | 7 #include "PluginDictionary.h" |
8 #include "PluginHttpRequest.h" | 8 #include "PluginHttpRequest.h" |
9 #include "PluginMutex.h" | 9 #include "PluginMutex.h" |
10 #include "PluginClass.h" | 10 #include "PluginClass.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 CloseHandle(processInformation.hProcess); | 38 CloseHandle(processInformation.hProcess); |
39 CloseHandle(processInformation.hThread); | 39 CloseHandle(processInformation.hThread); |
40 } | 40 } |
41 | 41 |
42 std::auto_ptr<Communication::Pipe> OpenAdblockPlusEnginePipe() | 42 std::auto_ptr<Communication::Pipe> OpenAdblockPlusEnginePipe() |
43 { | 43 { |
44 std::auto_ptr<Communication::Pipe> result; | 44 std::auto_ptr<Communication::Pipe> result; |
45 try | 45 try |
46 { | 46 { |
47 try | 47 result.reset(new Communication::Pipe(Communication::pipeName, |
| 48 Communication::Pipe::MODE_CONNECT)); |
| 49 } |
| 50 catch (Communication::PipeConnectionError e) |
| 51 { |
| 52 SpawnAdblockPlusEngine(); |
| 53 |
| 54 int timeout = 10000; |
| 55 const int step = 10; |
| 56 while (!result.get()) |
48 { | 57 { |
49 result.reset(new Communication::Pipe(Communication::pipeName, | 58 try |
50 Communication::Pipe::MODE_CONNECT)); | |
51 } | |
52 catch (Communication::PipeConnectionError e) | |
53 { | |
54 SpawnAdblockPlusEngine(); | |
55 | |
56 int timeout = 10000; | |
57 const int step = 10; | |
58 while (!result.get()) | |
59 { | 59 { |
60 try | 60 result.reset(new Communication::Pipe(Communication::pipeName, |
61 { | 61 Communication::Pipe::MODE_CONNECT)); |
62 result.reset(new Communication::Pipe(Communication::pipeName, | 62 } |
63 Communication::Pipe::MODE_CONNECT)); | 63 catch (Communication::PipeConnectionError e) |
64 } | 64 { |
65 catch (Communication::PipeConnectionError e) | 65 Sleep(step); |
66 { | 66 timeout -= step; |
67 Sleep(step); | 67 if (timeout <= 0) |
68 timeout -= step; | 68 throw std::runtime_error("Unable to open Adblock Plus Engine pipe"); |
69 if (timeout <= 0) | |
70 throw std::runtime_error("Unable to open Adblock Plus Engine pipe"
); | |
71 } | |
72 } | 69 } |
73 } | 70 } |
74 } | 71 } |
75 catch(std::exception e) | |
76 { | |
77 DEBUG_GENERAL(e.what()); | |
78 } | |
79 return result; | 72 return result; |
80 } | 73 } |
81 | 74 |
82 std::vector<std::string> ReadStrings(Communication::InputBuffer& message) | 75 std::vector<std::string> ReadStrings(Communication::InputBuffer& message) |
83 { | 76 { |
84 int32_t count; | 77 int32_t count; |
85 message >> count; | 78 message >> count; |
86 | 79 |
87 std::vector<std::string> result; | 80 std::vector<std::string> result; |
88 for (int32_t i = 0; i < count; i++) | 81 for (int32_t i = 0; i < count; i++) |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 try | 362 try |
370 { | 363 { |
371 CallAdblockPlusEngineProcedure(request); | 364 CallAdblockPlusEngineProcedure(request); |
372 } | 365 } |
373 catch (const std::exception& e) | 366 catch (const std::exception& e) |
374 { | 367 { |
375 DEBUG_GENERAL(e.what()); | 368 DEBUG_GENERAL(e.what()); |
376 } | 369 } |
377 } | 370 } |
378 | 371 |
OLD | NEW |