summaryrefslogtreecommitdiffstats
path: root/services/common_time
diff options
context:
space:
mode:
authorJohn Grossman <johngro@google.com>2012-08-21 16:39:11 -0700
committerJohn Grossman <johngro@google.com>2012-08-21 16:39:11 -0700
commit7a947c49782165d7320a93d8685d99730286f9a7 (patch)
treefd46b33beac102b5681ab23a0c18b3ed0fc144bd /services/common_time
parent5e8e41e41aecd2a4951659a1f3507f3371e0cc47 (diff)
downloadframeworks_base-7a947c49782165d7320a93d8685d99730286f9a7.zip
frameworks_base-7a947c49782165d7320a93d8685d99730286f9a7.tar.gz
frameworks_base-7a947c49782165d7320a93d8685d99730286f9a7.tar.bz2
common_time: Move default election config to bcast.
Change the default master election and arbiration to use broadcast instead of multicast. As nice as the idea of using multicast for discovery is, in the end it had just proven to be too unreliable in random people's home infrastructures as well as the more complicated managed infrastructures we are using internally. Multicast still works, and the service can still be configured to use it, but for now we are switching to broadcast. Also, add runtime checks to filter out our own broadcast traffic as there does not seem to be any good sockopt in linux to do this for us (there is one for multicast, but not broadcast). Change-Id: I8ada3541cceca2e76c7a0c1a624a72026122c312
Diffstat (limited to 'services/common_time')
-rw-r--r--services/common_time/common_time_server.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/services/common_time/common_time_server.cpp b/services/common_time/common_time_server.cpp
index 17f99b9..21e706f 100644
--- a/services/common_time/common_time_server.cpp
+++ b/services/common_time/common_time_server.cpp
@@ -53,9 +53,9 @@
namespace android {
-const char* CommonTimeServer::kDefaultMasterElectionAddr = "239.195.128.88";
-const uint16_t CommonTimeServer::kDefaultMasterElectionPort = 8887;
-const uint64_t CommonTimeServer::kDefaultSyncGroupID = 0;
+const char* CommonTimeServer::kDefaultMasterElectionAddr = "255.255.255.255";
+const uint16_t CommonTimeServer::kDefaultMasterElectionPort = 8886;
+const uint64_t CommonTimeServer::kDefaultSyncGroupID = 1;
const uint8_t CommonTimeServer::kDefaultMasterPriority = 1;
const uint32_t CommonTimeServer::kDefaultMasterAnnounceIntervalMs = 10000;
const uint32_t CommonTimeServer::kDefaultSyncRequestIntervalMs = 1000;
@@ -752,6 +752,9 @@ bool CommonTimeServer::handleTimeoutWaitForElection() {
bool CommonTimeServer::handleWhoIsMasterRequest(
const WhoIsMasterRequestPacket* request,
const sockaddr_storage& srcAddr) {
+ // Skip our own messages which come back via broadcast loopback.
+ if (request->senderDeviceID == mDeviceID)
+ return true;
char srcEPStr[64];
sockaddrToString(srcAddr, true, srcEPStr, sizeof(srcEPStr));
@@ -829,6 +832,10 @@ bool CommonTimeServer::handleWhoIsMasterRequest(
bool CommonTimeServer::handleWhoIsMasterResponse(
const WhoIsMasterResponsePacket* response,
const sockaddr_storage& srcAddr) {
+ // Skip our own messages which come back via broadcast loopback.
+ if (response->deviceID == mDeviceID)
+ return true;
+
char srcEPStr[64];
sockaddrToString(srcAddr, true, srcEPStr, sizeof(srcEPStr));
mElectionLog.log("RXed WhoIs master response while in state %s. "
@@ -996,6 +1003,10 @@ bool CommonTimeServer::handleMasterAnnouncement(
uint8_t newDevicePrio = packet->devicePriority;
uint64_t newTimelineID = packet->timelineID;
+ // Skip our own messages which come back via broadcast loopback.
+ if (newDeviceID == mDeviceID)
+ return true;
+
char srcEPStr[64];
sockaddrToString(srcAddr, true, srcEPStr, sizeof(srcEPStr));
mElectionLog.log("RXed master announcement while in state %s. "