Fix missing master maintainance loop bug (peers not timing out)

This commit is contained in:
Simon 2021-01-06 01:38:09 +00:00
parent 259c48f63c
commit 79a2dd1099
3 changed files with 23 additions and 25 deletions

View File

@ -624,17 +624,13 @@ def options_config():
tg = int(tg)
make_static_tg(tg,2,_tmout,_system)
systems[_system]._peer_sema.acquire(blocking=True)
_peerstmp = CONFIG['SYSTEMS'][_system]['PEERS']
CONFIG['SYSTEMS'][_system].update({
'TS1_STATIC' : _options['TS1_STATIC'],
'TS2_STATIC' : _options['TS2_STATIC'],
'DEFAULT_REFLECTOR' : int(_options['DEFAULT_REFLECTOR']),
'DEFAULT_UA_TIMER' : int(_options['DEFAULT_UA_TIMER']),
'PEERS' : _peerstmp
})
systems[_system]._peer_sema.release()
# systems[_system]._peer_sema.acquire(blocking=True)
# _peerstmp = CONFIG['SYSTEMS'][_system]['PEERS']
CONFIG['SYSTEMS'][_system]['TS1_STATIC'] = _options['TS1_STATIC']
CONFIG['SYSTEMS'][_system]['TS2_STATIC'] = _options['TS2_STATIC']
CONFIG['SYSTEMS'][_system]['DEFAULT_REFLECTOR'] = int(_options['DEFAULT_REFLECTOR'])
CONFIG['SYSTEMS'][_system]['DEFAULT_UA_TIMER'] = int(_options['DEFAULT_UA_TIMER'])
def mysql_config_check():
logger.debug('(MYSQL) Periodic config check')
@ -720,12 +716,11 @@ def mysql_config_check():
#Preserve options line
if 'OPTIONS' in CONFIG['SYSTEMS'][system]:
SQLCONFIG[system]['OPTIONS'] = CONFIG['SYSTEMS'][system]['OPTIONS']
SQLCONFIG[system].update({
'TS1_STATIC' : CONFIG['SYSTEMS'][system]['TS1_STATIC'],
'TS2_STATIC' : CONFIG['SYSTEMS'][system]['TS2_STATIC'],
'DEFAULT_UA_TIMER' : CONFIG['SYSTEMS'][system]['DEFAULT_UA_TIMER'],
'DEFAULT_REFLECTOR' : CONFIG['SYSTEMS'][system]['DEFAULT_REFLECTOR']
})
SQLCONFIG[system]['TS1_STATIC'] = CONFIG['SYSTEMS'][system]['TS1_STATIC']
SQLCONFIG[system]['TS2_STATIC'] = CONFIG['SYSTEMS'][system]['TS2_STATIC']
SQLCONFIG[system]['DEFAULT_UA_TIMER'] = CONFIG['SYSTEMS'][system]['DEFAULT_UA_TIMER']
SQLCONFIG[system]['DEFAULT_REFLECTOR'] = CONFIG['SYSTEMS'][system]['DEFAULT_REFLECTOR']
#logger.debug('(MYSQL) %s has HBP Options line - skipping',system)
#continue
@ -900,11 +895,14 @@ def mysql_config_check():
logger.debug('(MYSQL) TG2 ACL changed')
#Preserve peers list
if system in CONFIG['SYSTEMS'] and CONFIG['SYSTEMS'][system]['ENABLED']:
if system in CONFIG['SYSTEMS'] and CONFIG['SYSTEMS'][system]['ENABLED'] and 'PEERS' in CONFIG['SYSTEMS'][system] :
systems[system]._peer_sema.acquire(blocking=True)
SQLCONFIG[system]['PEERS'] = CONFIG['SYSTEMS'][system]['PEERS']
CONFIG['SYSTEMS'][system].update(SQLCONFIG[system])
systems[system]._peer_sema.release()
CONFIG['SYSTEMS'][system].update(SQLCONFIG[system])
else:
CONFIG['SYSTEMS'][system].update(SQLCONFIG[system])
#Add MySQL config data to config dict
#CONFIG['SYSTEMS'].update(SQLCONFIG)

View File

@ -253,9 +253,9 @@ class HBSYSTEM(DatagramProtocol):
# Remove any timed out peers from the configuration
del self._CONFIG['SYSTEMS'][self._system]['PEERS'][peer]
self._peer_sema.release()
if not self._peers and self._CONFIG['OPTIONS']:
if 'PEERS' not in self._CONFIG['SYSTEMS'][self._system] and 'OPTIONS' in self._CONFIG['SYSTEMS'][self._system]:
logger.info('(%s) Deleting HBP Options',self._system)
del self._CONFIG['OPTIONS']
del self._CONFIG['SYSTEMS'][self._system]['OPTIONS']
# Aliased in __init__ to maintenance_loop if system is a peer
def peer_maintenance_loop(self):

View File

@ -67,9 +67,9 @@ class Proxy(DatagramProtocol):
_peer_id = self.connTrack[port]
elif _command == MSTN:
_peer_id = data[6:10]
#self.peerTrack[_peer_id]['timer'].cancel()
#self.reaper(_peer_id)
#return
self.peerTrack[_peer_id]['timer'].cancel()
self.reaper(_peer_id)
return
elif _command == MSTP:
_peer_id = data[7:11]
elif _command == MSTC:
@ -147,7 +147,7 @@ if __name__ == '__main__':
Master = "127.0.0.1"
ListenPort = 62031
DestportStart = 5000
DestportStart = 50000
DestPortEnd = 50600
Timeout = 30
Stats = True