Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(562)

Unified Diff: ceee/ie/broker/broker_rpc_server.cc

Issue 5258006: Restart of ceee_broker on crash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ceee/ie/broker/broker_rpc_lib.idl ('k') | ceee/ie/broker/broker_rpc_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ceee/ie/broker/broker_rpc_server.cc
===================================================================
--- ceee/ie/broker/broker_rpc_server.cc (revision 67905)
+++ ceee/ie/broker/broker_rpc_server.cc (working copy)
@@ -7,8 +7,9 @@
#include "ceee/ie/broker/broker_rpc_server.h"
#include "base/atomic_sequence_num.h"
+#include "base/logging.h"
#include "base/metrics/histogram.h"
-#include "base/logging.h"
+#include "base/process_util.h"
#include "base/win_util.h"
#include "broker_rpc_lib.h" // NOLINT
#include "ceee/common/com_utils.h"
@@ -16,10 +17,40 @@
#include "ceee/ie/broker/broker_rpc_utils.h"
#include "ceee/ie/broker/chrome_postman.h"
+
+namespace {
// This lock ensures that histograms created by the broker are thread safe.
// The histograms created here can be initialized on multiple threads.
Lock g_metrics_lock;
+RPC_STATUS PrepareEndpoint(std::wstring endpoint) {
+ std::wstring protocol = kRpcProtocol;
+ DCHECK(!protocol.empty());
+ DCHECK(!endpoint.empty());
+ if (protocol.empty() || endpoint.empty())
+ return false;
+ VLOG(1) << "RPC server is starting. Endpoint: " << endpoint;
+ // Tell RPC runtime to use local interprocess communication for given
+ // end point.
+ RPC_STATUS status = ::RpcServerUseProtseqEp(
+ reinterpret_cast<RPC_WSTR>(&protocol[0]),
+ RPC_C_PROTSEQ_MAX_REQS_DEFAULT,
+ reinterpret_cast<RPC_WSTR>(&endpoint[0]),
+ NULL);
+ LOG_IF(ERROR, RPC_S_OK != status && RPC_S_DUPLICATE_ENDPOINT != status) <<
+ "Failed to set protocol for RPC end point. RPC_STATUS=0x" <<
+ com::LogWe(status);
+ // This is not an error because unittest may start several servers. For
+ // ceee_broker this is an error because we should not have several instances
+ // of broker for the same endpoint. However BrokerRpcServer will fail anyway
+ // while starting to listen.
+ if (RPC_S_DUPLICATE_ENDPOINT == status)
+ status = RPC_S_OK;
+ return status;
+}
+
+} // namespace
+
BrokerRpcServer::BrokerRpcServer()
: is_started_(false),
current_thread_(::GetCurrentThreadId()) {
@@ -36,25 +67,10 @@
if (is_started())
return true;
- std::wstring end_point = GetRpcEndPointAddress();
- std::wstring protocol = kRpcProtocol;
- DCHECK(!protocol.empty());
- DCHECK(!end_point.empty());
- if (protocol.empty() || end_point.empty())
- return false;
+ std::wstring endpoint = GetRpcEndpointAddress();
+ RPC_STATUS status = PrepareEndpoint(endpoint);
- LOG(INFO) << "RPC server is starting. Endpoint: " << end_point;
- // Tell RPC runtime to use local interprocess communication for given
- // end point.
- RPC_STATUS status = ::RpcServerUseProtseqEp(
- reinterpret_cast<RPC_WSTR>(&protocol[0]),
- RPC_C_PROTSEQ_MAX_REQS_DEFAULT,
- reinterpret_cast<RPC_WSTR>(&end_point[0]),
- NULL);
- LOG_IF(ERROR, RPC_S_OK != status && RPC_S_DUPLICATE_ENDPOINT != status) <<
- "Failed to set protocol for RPC end point. RPC_STATUS=0x" <<
- com::LogWe(status);
- if (RPC_S_OK == status || RPC_S_DUPLICATE_ENDPOINT == status) {
+ if (RPC_S_OK == status) {
// Register RPC interface with the RPC runtime.
status = ::RpcServerRegisterIfEx(BrokerRpcServer_CeeeBroker_v1_1_s_ifspec,
NULL, NULL, 0, RPC_C_LISTEN_MAX_CALLS_DEFAULT, NULL);
@@ -66,7 +82,7 @@
LOG_IF(ERROR, RPC_S_OK != status) <<
"Failed to start listening. RPC_STATUS=0x" << com::LogWe(status);
if (RPC_S_OK == status) {
- LOG(INFO) << "RPC server is started. Endpoint: " << end_point;
+ VLOG(1) << "RPC server is started. Endpoint: " << endpoint;
is_started_ = true;
}
}
@@ -82,17 +98,19 @@
is_started_ = false;
// Stop server listening for RPC.
RPC_STATUS status = ::RpcMgmtStopServerListening(NULL);
- LOG_IF(WARNING, RPC_S_OK != status) <<
- "Failed to stop listening. RPC_STATUS=0x" << com::LogWe(status);
+ LOG_IF(WARNING, RPC_S_OK != status && RPC_S_NOT_LISTENING != status) <<
+ "Failed to stop listening. RPC_STATUS=0x" << com::LogWe(status);
// Wait while server stops listening threads.
status = ::RpcMgmtWaitServerListen();
- LOG_IF(WARNING, RPC_S_OK != status) <<
- "Failed to wait server listen. RPC_STATUS=0x" << com::LogWe(status);
+ LOG_IF(WARNING, RPC_S_OK != status && RPC_S_NOT_LISTENING != status) <<
+ "Failed to wait server listen. RPC_STATUS=0x" << com::LogWe(status);
// Unregister RPC interface.
status = ::RpcServerUnregisterIf(
BrokerRpcServer_CeeeBroker_v1_1_s_ifspec, NULL, FALSE);
- LOG_IF(WARNING, RPC_S_OK != status) <<
- "Failed to unregister interface. RPC_STATUS=0x" << com::LogWe(status);
+ LOG_IF(WARNING, RPC_S_OK != status || RPC_S_UNKNOWN_MGR_TYPE != status ||
+ RPC_S_UNKNOWN_IF != status) <<
+ "Failed to unregister interface. RPC_STATUS=0x" << com::LogWe(status);
+
return RPC_S_OK == status;
}
« no previous file with comments | « ceee/ie/broker/broker_rpc_lib.idl ('k') | ceee/ie/broker/broker_rpc_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698