summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjoi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-23 03:22:24 +0000
committerjoi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-23 03:22:24 +0000
commit97c6500777e5329359456417f12ea083cea9777a (patch)
tree85d2f889e4add20e98744587c0f7d084c0e63d75
parentc4ecdcf9dca8e16a46f327318b1994f19ca3dbef (diff)
downloadchromium_src-97c6500777e5329359456417f12ea083cea9777a.zip
chromium_src-97c6500777e5329359456417f12ea083cea9777a.tar.gz
chromium_src-97c6500777e5329359456417f12ea083cea9777a.tar.bz2
Committing patch http://codereview.chromium.org/5288001/ from vitalybuka@google.com.
BUG=none TEST=none Review URL: http://codereview.chromium.org/5284002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67059 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ceee/ie/broker/broker_module.cc23
1 files changed, 18 insertions, 5 deletions
diff --git a/ceee/ie/broker/broker_module.cc b/ceee/ie/broker/broker_module.cc
index bdfec36..0d7a0eb 100644
--- a/ceee/ie/broker/broker_module.cc
+++ b/ceee/ie/broker/broker_module.cc
@@ -76,6 +76,8 @@ class CeeeBrokerModule : public CAtlExeModuleT<CeeeBrokerModule> {
HRESULT PostMessageLoop();
HRESULT PreMessageLoop(int show);
private:
+ void TearDown();
+
// We maintain a postman COM object on the stack so that we can
// properly initialize and terminate it at the right time.
CComObjectStackEx<ChromePostman> chrome_postman_;
@@ -162,17 +164,30 @@ HRESULT CeeeBrokerModule::PreMessageLoop(int show) {
chrome_postman_.Init();
WindowEventsFunnel::Initialize();
- if (!rpc_server_.Start())
- return RPC_E_FAULT;
+ // Another instance of broker may be shutting down right now. Do several
+ // attempts in hope the process exits and releases endpoint.
+ for (int i = 0; i < 10 && !rpc_server_.Start(); ++i)
+ Sleep(500);
// Initialize metrics. We need the rpc_server_ above to be available.
MetricsService::Start();
- return CAtlExeModuleT<CeeeBrokerModule>::PreMessageLoop(show);
+ HRESULT hr = rpc_server_.is_started() ? S_OK : RPC_E_FAULT;
+ if (SUCCEEDED(hr))
+ hr = CAtlExeModuleT<CeeeBrokerModule>::PreMessageLoop(show);
+ if (FAILED(hr))
+ TearDown();
+ return hr;
}
HRESULT CeeeBrokerModule::PostMessageLoop() {
HRESULT hr = CAtlExeModuleT<CeeeBrokerModule>::PostMessageLoop();
+ TearDown();
+ return hr;
+}
+
+void CeeeBrokerModule::TearDown() {
+ rpc_server_.Stop();
Singleton<ExecutorsManager,
ExecutorsManager::SingletonTraits>()->Terminate();
WindowEventsFunnel::Terminate();
@@ -181,13 +196,11 @@ HRESULT CeeeBrokerModule::PostMessageLoop() {
MetricsService::Stop();
chrome_postman_.Term();
- return hr;
}
CeeeBrokerModule::~CeeeBrokerModule() {
crash_reporter_.ShutdownCrashReporting();
logging::CloseLogFile();
-
TRACE_EVENT_END("ceee.broker", this, "");
}