summaryrefslogtreecommitdiff
path: root/server/RouteController.cpp
diff options
context:
space:
mode:
authorLuke Huang <huangluke@google.com>2018-06-29 13:49:58 +0800
committerLuke Huang <huangluke@google.com>2018-07-11 15:04:07 +0800
commitd1ee462e94c34193bf5e8eb2975fff61b82ab1fb (patch)
treedd8ba06ec3939751c61f9f1a672b2474729f2e5f /server/RouteController.cpp
parentd4c0be8ed437ee2198a0d5d8561093ab23e51c2e (diff)
Replace RW lock with mutex, shared_mutex
Test: built, flashed, booted system/netd/tests/runtests.sh passes Change-Id: I42b52d815b6ba0ba6f93dc27e83a900d2abec715
Diffstat (limited to 'server/RouteController.cpp')
-rw-r--r--server/RouteController.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/server/RouteController.cpp b/server/RouteController.cpp
index c78854d8..ccec437d 100644
--- a/server/RouteController.cpp
+++ b/server/RouteController.cpp
@@ -155,7 +155,7 @@ uint32_t RouteController::getRouteTableForInterfaceLocked(const char* interface)
}
uint32_t RouteController::getIfIndex(const char* interface) {
- android::RWLock::AutoRLock lock(sInterfaceToTableLock);
+ std::shared_lock<std::shared_mutex> lock(sInterfaceToTableLock);
auto iter = sInterfaceToTable.find(interface);
if (iter == sInterfaceToTable.end()) {
@@ -167,7 +167,7 @@ uint32_t RouteController::getIfIndex(const char* interface) {
}
uint32_t RouteController::getRouteTableForInterface(const char* interface) {
- android::RWLock::AutoRLock lock(sInterfaceToTableLock);
+ std::shared_lock<std::shared_mutex> lock(sInterfaceToTableLock);
return getRouteTableForInterfaceLocked(interface);
}
@@ -191,7 +191,7 @@ void RouteController::updateTableNamesFile() {
addTableName(ROUTE_TABLE_LEGACY_NETWORK, ROUTE_TABLE_NAME_LEGACY_NETWORK, &contents);
addTableName(ROUTE_TABLE_LEGACY_SYSTEM, ROUTE_TABLE_NAME_LEGACY_SYSTEM, &contents);
- android::RWLock::AutoRLock lock(sInterfaceToTableLock);
+ std::shared_lock<std::shared_mutex> lock(sInterfaceToTableLock);
for (const auto& entry : sInterfaceToTable) {
addTableName(entry.second, entry.first, &contents);
}
@@ -927,7 +927,7 @@ WARN_UNUSED_RESULT int RouteController::flushRoutes(uint32_t table) {
// Returns 0 on success or negative errno on failure.
WARN_UNUSED_RESULT int RouteController::flushRoutes(const char* interface) {
- android::RWLock::AutoWLock lock(sInterfaceToTableLock);
+ std::lock_guard<std::shared_mutex> lock(sInterfaceToTableLock);
uint32_t table = getRouteTableForInterfaceLocked(interface);
if (table == RT_TABLE_UNSPEC) {
@@ -1089,9 +1089,9 @@ int RouteController::removeVirtualNetworkFallthrough(unsigned vpnNetId,
}
// Protects sInterfaceToTable.
-android::RWLock RouteController::sInterfaceToTableLock;
-
+std::shared_mutex RouteController::sInterfaceToTableLock;
std::map<std::string, uint32_t> RouteController::sInterfaceToTable;
+
} // namespace net
} // namespace android