@@ -80,14 +80,14 @@ const int CommonTimeServer::kInitial_WhoIsMasterTimeoutMs = 500;
8080
8181// number of sync requests that can fail before a client assumes its master
8282// is dead
83- const int CommonTimeServer::kClient_NumSyncRequestRetries = 5 ;
83+ const int CommonTimeServer::kClient_NumSyncRequestRetries = 10 ;
8484
8585/* ** Master state constants ***/
8686
8787/* ** Ronin state constants ***/
8888
8989// number of WhoIsMaster attempts sent before declaring ourselves master
90- const int CommonTimeServer::kRonin_NumWhoIsMasterRetries = 4 ;
90+ const int CommonTimeServer::kRonin_NumWhoIsMasterRetries = 20 ;
9191
9292// timeout used when waiting for a response to a WhoIsMaster request
9393const int CommonTimeServer::kRonin_WhoIsMasterTimeoutMs = 500 ;
@@ -96,7 +96,7 @@ const int CommonTimeServer::kRonin_WhoIsMasterTimeoutMs = 500;
9696
9797// how long do we wait for an announcement from a master before
9898// trying another election?
99- const int CommonTimeServer::kWaitForElection_TimeoutMs = 5000 ;
99+ const int CommonTimeServer::kWaitForElection_TimeoutMs = 12500 ;
100100
101101CommonTimeServer::CommonTimeServer ()
102102 : Thread(false )
@@ -279,10 +279,14 @@ bool CommonTimeServer::runStateMachine_l() {
279279 // If we were in the master state, then either we were the
280280 // master in a no-network situation, or we were the master
281281 // of a different network and have moved to a new interface.
282- // In either case, immediately send out a master
283- // announcement at low priority.
282+ // In either case, immediately transition to Ronin at low
283+ // priority. If there is no one in the network we just
284+ // joined, we will become master soon enough. If there is,
285+ // we want to be certain to defer master status to the
286+ // existing timeline currently running on the network.
287+ //
284288 case CommonClockService::STATE_MASTER:
285- sendMasterAnnouncement ( );
289+ becomeRonin ( " leaving networkless mode " );
286290 break ;
287291
288292 // If we were in any other state (CLIENT, RONIN, or
@@ -1072,6 +1076,12 @@ bool CommonTimeServer::becomeClient(const sockaddr_storage& masterEP,
10721076
10731077 mMasterEP = masterEP;
10741078 mMasterEPValid = true ;
1079+
1080+ // If we are on a real network as a client of a real master, then we should
1081+ // no longer force low priority. If our master disappears, we should have
1082+ // the high priority bit set during the election to replace the master
1083+ // because this group was a real group and not a singleton created in
1084+ // networkless mode.
10751085 setForceLowPriority (false );
10761086
10771087 mClient_MasterDeviceID = masterDeviceID;
@@ -1113,7 +1123,6 @@ bool CommonTimeServer::becomeMaster(const char* cause) {
11131123
11141124 memset (&mMasterEP , 0 , sizeof (mMasterEP ));
11151125 mMasterEPValid = false ;
1116- setForceLowPriority (false );
11171126 mClient_MasterDevicePriority = effectivePriority ();
11181127 mClient_MasterDeviceID = mDeviceID ;
11191128 mClockRecovery .reset (false , true );
0 commit comments