summaryrefslogtreecommitdiffstats
path: root/services/common_time
diff options
context:
space:
mode:
authorJason Simmons <jsimmons@google.com>2012-07-17 15:48:53 -0700
committerJason Simmons <jsimmons@google.com>2012-07-17 18:02:24 -0700
commitdb63260758ad795d619073e41f273184ab629bbc (patch)
treee46b6aab200b4a9d3156c42515cfecea3cdf7809 /services/common_time
parent6b7358d9511df7e519bb417fbed6017c06a33d45 (diff)
downloadframeworks_base-db63260758ad795d619073e41f273184ab629bbc.zip
frameworks_base-db63260758ad795d619073e41f273184ab629bbc.tar.gz
frameworks_base-db63260758ad795d619073e41f273184ab629bbc.tar.bz2
Set the SO_BROADCAST option if the master election endpoint is the broadcast address
Change-Id: I75b3815be73744b99a4bea52916984de76634e7e
Diffstat (limited to 'services/common_time')
-rw-r--r--services/common_time/common_time_server.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/services/common_time/common_time_server.cpp b/services/common_time/common_time_server.cpp
index 4e5d16e..0125709 100644
--- a/services/common_time/common_time_server.cpp
+++ b/services/common_time/common_time_server.cpp
@@ -487,7 +487,16 @@ bool CommonTimeServer::setupSocket_l() {
goto bailout;
}
} else
- if (ntohl(ipv4_addr->sin_addr.s_addr) != 0xFFFFFFFF) {
+ if (ntohl(ipv4_addr->sin_addr.s_addr) == 0xFFFFFFFF) {
+ // If the master election address is the broadcast address, then enable
+ // the broadcast socket option
+ const int one = 1;
+ rc = setsockopt(mSocket, SOL_SOCKET, SO_BROADCAST, &one, sizeof(one));
+ if (rc == -1) {
+ ALOGE("Failed to enable broadcast (errno = %d)", errno);
+ goto bailout;
+ }
+ } else {
// If the master election address is neither broadcast, nor multicast,
// then we are misconfigured. The config API layer should prevent this
// from ever happening.